Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 2901

General Debian • Re: Share your Debian SCRIPTS

$
0
0
disclaimer: I'm pretty anal about backups :)

Thought I would share part of my backup solution. There are four Debian machines here - each machine has a script that backs up the important stuff to a server drive - the machines are scheduled 30 minutes apart. To optimize the backup all six of the rsync tasks below run in parallel. The local machine scripts are simple, they look like this -backups are pretty speedy, if there's nothing to sync this script takes less than a minute to run. Breakdown below the script -

Code:

#!/bin/bashdpkg --get-selections > /etc/apt/dpkg-selections.listif mountpoint -q /media/server-internal; then    /usr/bin/rsync -qa --chown=wizard:wizard --del /etc/ /media/server-internal/laptop/etc &    /usr/bin/rsync -qa --chown=wizard:wizard --del /usr/local/ /media/server-internal/laptop/usr-local &    /usr/bin/rsync -qa --chown=wizard:wizard /home/wizard/documents/ /media/server-internal/documents &    /usr/bin/rsync -qa --chown=wizard:wizard /home/wizard/pictures/ /media/server-internal/pictures &    /usr/bin/rsync -qa --chown=wizard:wizard --exclude-from=/usr/local/etc/rsync/exclude --del /root/ /media/server-internal/laptop/root &    /usr/bin/rsync -qa --chown=wizard:wizard --exclude-from=/usr/local/etc/rsync/exclude --del /home/wizard/ /media/server-internal/laptop/homeelse    exit 1fisyncswapoff -a && swapon -aexit 0
First thing I do is create a dump of packages I have installed and stick that list in /etc/apt so I can use it to restore applications I had installed.

Next, we use mountpoint to check to see if the target drive is actually mounted; if it's not mounted the script sets an errorlevel an exits,

The six rsync jobs are run in parallel instead of sequentially (notice that five of them end in "&").

After that we sync filesystems to ensure disk writes are complete and clear swap before exiting the script.

The server-side backup script also copies backups from all four machines to gdrive, syncs documents and pictures back to all four machines so all four machines have the same content and then clones the backup drive to two additional drives, on mounted on the server and another mounted on another machine on the network.

¿See? Toldja I was pretty anal about backups :D Hope this gives some folks ideas about backing up their own systems.

Statistics: Posted by wizard10000 — 2024-08-09 12:54



Viewing all articles
Browse latest Browse all 2901

Trending Articles