Created
August 26, 2011 08:26
-
-
Save endymuhardin/1172978 to your computer and use it in GitHub Desktop.
Backup Script untuk Home Folder
This file contains hidden or 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
rsync -avzPH /opt/downloads/backups /media/DATA2/ |
This file contains hidden or 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
0 */3 * * * /path/ke/rsync-backup-home.sh /home/endy /opt/downloads/backups /path/ke/rsync-exclude.txt |
This file contains hidden or 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
./rsync-backup-home.sh /home/endy /opt/downloads/backups rsync-exclude.txt |
This file contains hidden or 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
ls -ltr /opt/downloads/backups/ | |
total 12 | |
drwxr-xr-x 3 endy endy 4096 2011-08-26 13:21 20110826-1321 | |
drwxr-xr-x 3 endy endy 4096 2011-08-26 14:07 20110826-1407 | |
drwxr-xr-x 3 endy endy 4096 2011-08-26 14:27 20110826-1427 |
This file contains hidden or 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
ls -tr /opt/downloads/backups/ | tail -1 | |
20110826-1427 |
This file contains hidden or 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
#!/usr/bin/env bash | |
# run hourly with cron | |
# 0 * * * * /path/ke/rsync-backup.sh /home/endy /opt/downloads/backups /path/ke/rsync-exclude.txt | |
SRC=$1 | |
DEST=$2 | |
EXCLUDES=$3 | |
args=("$@"); | |
MORE_OPTS=${args[@]:3} | |
if [ "$#" -lt 3 ]; then | |
echo "Usage : $0 <src> <dest> <exclude list> [rsync options]" | |
return 1 | |
fi | |
LAST=$(ls -tr $DEST | tail -1) | |
if [ "$LAST" != "" ]; then | |
LINK="--link-dest=$DEST/$LAST" | |
fi | |
OPTS=" -a --force --ignore-errors --exclude-from=$EXCLUDES $LINK" | |
# echo OPTS $OPTS MORE_OPTS $MORE_OPTS | |
rsync $OPTS $MORE_OPTS $SRC $DEST/$(date +%Y%m%d-%H%M) |
This file contains hidden or 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
rsync -a --force --ignore-errors --exclude-from=rsync-exclude.txt --link-dest=folder-backup-sebelumnya SRC DEST |
This file contains hidden or 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
#rsync script exclude file | |
**/.thumbnails/ | |
**/Desktop/Trash/ | |
**/.cache/ | |
**/.m2/ | |
**/.metadata/ | |
**/.netbeans/ | |
**/.shotwell/ | |
**/.config/ | |
**/.gconf/ | |
**/virtual-machines/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment