Here's something for you.
These are a couple of scripts that I use to backup data. The first one creates a full backup. The second makes a differential backup, on a different directory. I modified them with what I think are your own directories. Replace 'your_user' with your actual username.
full.sh:
Code:
#!/bin/bash
SOURCE="/var/www/my_web/load/"
BACKUP="/home/your_user/load/"
DATE=$(date +%Y-%m-%d-%T)
DESTINATION="$BACKUP"/"$DATE"-full/
# the symbolic link 'latest-full' will always point to the lastest full backup.
rm -rf "$BACKUP"/latest-full
ln -s "$DESTINATION" "$BACKUP"/latest-full
rsync -av "$SOURCE" "$DESTINATION"
differential.sh:
Code:
#!/bin/bash
SOURCE="/var/www/my_web/load/"
BACKUP="/home/your_user/load/"
LBACKUP="/home/your_user/load/latest-full/"
DATE=$(date +%Y-%m-%d-%T)
DESTINATION="$BACKUP"/"$DATE"-diff/
rsync -av --compare-dest="$LBACKUP" "$SOURCE" "$DESTINATION"
# delete empty directories (rsync copies the whole tree).
cd "$DESTINATION"
find . -depth -type d -empty -delete
I hope they provide some ideas to you.
Kind Regards.
Bookmarks