Created
May 3, 2012 11:47
-
-
Save weakish/2585180 to your computer and use it in GitHub Desktop.
#incremental #backup using #tar #sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# by Jakukyo Friel <weakish@gmail.com> under GPL-2 | |
### Incremental backup using tar | |
## Usage: | |
# backup /path/to/dir/ | |
# Backup files will be put in the current directory. | |
# Suppose foo is the basename of the backing up directory, | |
# backup files will be named as: | |
# - foo.txz (full backup, we use xz compression) | |
# - foo.YY-MM-DD.txz (incremental level-1 backup) | |
# - foo.snar (incremental list file) | |
base_name=`basename $*` | |
level0=$base_name.txz | |
level1=$base_name.`date +%F`.txz | |
incremental_list=$base_name.snar | |
original_incremental_list=$incremental_list.orig | |
if [ -e $original_incremental_list ]; then | |
cp $original_incremental_list $incremental_list | |
tar -cJf $level1 -g $incremental_list $* | |
else | |
tar -cJf $level0 -g $incremental_list $* | |
cp $incremental_list $original_incremental_list | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment