Skip to content

Instantly share code, notes, and snippets.

@endymuhardin
Created August 26, 2011 08:26
Show Gist options
  • Save endymuhardin/1172978 to your computer and use it in GitHub Desktop.
Save endymuhardin/1172978 to your computer and use it in GitHub Desktop.
Backup Script untuk Home Folder
rsync -avzPH /opt/downloads/backups /media/DATA2/
0 */3 * * * /path/ke/rsync-backup-home.sh /home/endy /opt/downloads/backups /path/ke/rsync-exclude.txt
./rsync-backup-home.sh /home/endy /opt/downloads/backups rsync-exclude.txt
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
ls -tr /opt/downloads/backups/ | tail -1
20110826-1427
#!/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)
rsync -a --force --ignore-errors --exclude-from=rsync-exclude.txt --link-dest=folder-backup-sebelumnya SRC DEST
#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