Simple backup using revision control (Linux)
Previously I’ve used scripts with static paths to create backups, switching to revision control simplified things a lot. Combine with cron and you have a pretty powerful backup system.
I use this to backup global and user config files (/etc, ~/.config etc)
Install a revision control application
There are a lot to choose from (CVS, SVN, BZR, GIT etc.). Pick one and emerge. I strongly recommend GIT (for any purpose). In this example BZR is used, because I haven’t updated it yet.
Set up a cron-job
In wixie cron add a file called /etc/cron.daily/backup and make it executable. This will create a daily backup routine. Here is my script. It exports the current revision to a bzipped archive on a USB-stick (if mounted) with GPG encryption.
CURRENT_DATE=`date +"%d-%m-%y"` DESTINATION="/media/backup-pin" BZR="/" TAR="$DESTINATION/backup-$CURRENT_DATE.tar.bz2" PGP_ID="YOUR_ID_HERE" if [ -d "$DESTINATION" ]; then # Only exists when mounted bzr export $TAR $BZR if [ $? -eq 0 ]; then gpg -e -r "$PGP_ID" $TAR if [ $? -eq 0 ]; then rm -f $TAR # Remove temporary file fi fi fi
Add files and file filters
In /.bzrignore (.gitignore etc) add “*” so you ignore all files except those you manually add.
About this entry
You’re currently reading “Simple backup using revision control (Linux),” an entry on Anders Evenrud's Blog
- Published:
- November 9, 2009 / 17:20
- Category:
- Gentoo Experiments, Linux General
No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]