Skip to content

Instantly share code, notes, and snippets.

@andreisavu
Created September 8, 2009 15:19
Show Gist options
  • Save andreisavu/182999 to your computer and use it in GitHub Desktop.
Save andreisavu/182999 to your computer and use it in GitHub Desktop.
# smart backup using rsync : rsync_snapshot
# http://www.mikerubel.org/computers/rsync_snapshots/
mv backup.3 backup.tmp
mv backup.2 backup.3
mv backup.1 backup.2
mv backup.0 backup.1
mv backup.tmp backup.0
cp -al backup.1/. backup.0
rsync -a --delete source_directory/ backup.0/
http://www.mikerubel.org/computers/rsync_snapshots/contributed/martijn_kruissen
I did some alterations as I wanted to backup more than just
the home dir. The include file determines what is to be
backed up now.
The new rsync command (now uses in and excludes and "/" as src) :
$RSYNC \
-va --delete --delete-excluded \
--exclude-from="$EXCLUDES" \
--include-from="$INCLUDES" \
/ $SNAPSHOT_RW/home/daily.0 ;
Exclude file (the stuff we dont want) :
#rsync script exclude file
**/.pan/messages/cache/
**/.phoenix/default/*/Cache/
**/.thumbnails/
**/Desktop/Trash/
Include (what dirs to be included):
#rsync script include file
/home/
/home/**
/var/
/var/www/
/var/www/**
/etc/
/etc/**
- *
Note the "- *" for excluding everything except the dirs mentioned
in the include file.
Also note the "/var/" entry. To backup /var/www/* , you need to
include /var/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment