Linux Backup Scripts
How it works
This script will backup the current users home directory. It will do an incremental backup using hard-links. Therefore the directory that will hold the backups has to be on a file system capable of hard-links. Also the script internally uses rsync, so rsync has to be installed. The script will generate directories of the form <user name>-<date>-<time>. Here is how a typical backup-directory may look:
lanserver home # ls -l total 24 lrwxrwxrwx 1 root root 23 Mar 3 2008 last -> seiichiro-20080303-2159 drwxr-xr-x 118 seiichiro users 12288 Mar 2 14:24 seiichiro-20080302-2104 drwxr-xr-x 118 seiichiro users 12288 Mar 3 18:46 seiichiro-20080303-2159
As one can see there are two backups here and one symbolic link “last” to the newest backup which is used by the script to determine what needs to get backed up during the next run.
How to run it
The script has two modes of operation: local and remote. They are determined automatically from the form of the command-line parameter you give:
for local backup the one and only argument is simply the directory where the backup should be stored.
for remote the argument has two parts separated by a “:” root@lanserver is user name and dns-name/ip of the remote server where the backup should be stored, after the colon you put the path on the server to the backup-dir. It is a good idea to have a ssh-agent running and public-key login on the server or you will have to type in the password multiple times during operation of the script.
Get the script
So if you think this script is useful for you get it from here:
How it works
This script will create a tar.gz from your running linux system (also known as “stage4” to gentoo users). This tar.gz is a full copy of your System. If your system dies from eg a harddrive crash you can restore it on a new drive by simply recreating the partitions, unpacking the tar.gz on them and reinstall the bootloader.
Configuring and Running the Script
Before the first run on a particular system you will need to customize the 3 variables in the configure-section if the script. Open the script and change the variables to match your systems configuration (for explanation/examples see the script).
After configuring you can now run the script. The script takes one neccessary and one optional argument. The first argument has to be the directory where to store the backup and the second one can be a name for the backup file (usefull if you backup many systems to the same directory). An example of calling the script could look as follows:
sysbackup-tar.sh /mnt/backup/ laptop
This call would create the backupfile
Get the script
So for all who think this script may be usefull, here it is:
If you have questions or suggestions drop me a mail at firstname.lastname@example.org