| Its dark in here
Join Date: Jun 2006 Location: /home/yurimxpxman
Posts: 1,693
| differential backups script for Unix After hearing a friend brag about his company's 1/4 million dollar differential versioning system, I did a search for differential backup tools for Unix so I could do the same thing at home with my code. After a few minutes, I found the rdiff-backup utility (you probably already have it; if not, check your package manager, or download it here). I then came up with this short script to make the job semi-automatic. So basically, this will backup your entire home directory to another partition without wasting space on duplicate files.
Note that this script was written for the BASH shell, so you'll have to change it a bit to get it to run with ash. Also, you'll want to change the path to your backup destination.
To use the script, paste the following code into a text editor and save it as /usr/bin/baxup. To run the script, just run the "baxup" command from anywhere you like, whether it's a terminal or a startup entry, etc. The file will need executable permissions to run; you can do so with the following command, assuming you're a sudo user: Code: sudo chmod +x /usr/bin/baxup
To restore the backup, use "baxup -r". This will restore a three day-old copy of your files to a directory named "old" on your desktop. Code: #!/bin/bash
# baxup - a shell script to semi-automate the process of backing up
# your home directory
# (c) 2007 Joshua David Williams, licensed under the GPL
# EULA: http://www.gnu.org/licenses/gpl.txt
# Change the value of this variable to the destination of the backup:
D="/media/JOSH/bak/"
if [[ $1 =~ "-r" ]]; then
rdiff-backup -r 3D $D ~/Desktop/old
else if [[ $1 =~ "-h" ]]; then
printf "Creates a differential backup. To restore, use the -r command argument.\n"
else
rdiff-backup --include ~/tmp/keep --exclude ~/tmp ~/ $D
fi
fi
Last edited by yurimxpxman; May 17th, 2007 at 08:28.
|