Created
October 28, 2017 00:07
-
-
Save stroebs/e25e9afd167e9fc61ede715a865f0a99 to your computer and use it in GitHub Desktop.
Simple tar + rsync backup method
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/bash | |
DATE=$(date +%Y%m%d) | |
FILE="backup-$DATE.tar.gz" | |
LOG="/tmp/backup-$DATE.log" | |
RSYNC_PASSWORD="supersecret" | |
RSYNC_CMD="-a --delete /$FILE rsync://[email protected]:/backup-dir/daily/" | |
export RSYNC_PASSWORD=$RSYNC_PASSWORD | |
cd / | |
tar -cpzf $FILE \ | |
--exclude=/*.tar.gz \ | |
--exclude=/proc \ | |
--exclude=/tmp \ | |
--exclude=/mnt \ | |
--exclude=/dev \ | |
--exclude=/sys \ | |
--exclude=/run \ | |
--exclude=/media \ | |
--exclude=/var/log \ | |
--exclude=/var/cache/apt/archives \ | |
--exclude=/usr/src/linux-headers* \ | |
--exclude=/home / | |
rsync $RSYNC_CMD | |
rm -rf /$FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment