Created
October 14, 2013 15:16
-
-
Save Gargron/6977277 to your computer and use it in GitHub Desktop.
Script to do an incremental backup of the home directory of a user
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
#! /bin/sh | |
DRIVE_PATH="/path/to/drive" | |
USER="joe" | |
BACKUP_PATH="$DRIVE_PATH/backups/$USER@$(hostname)" | |
if command -v rdiff-backup >/dev/null 2>&1; then | |
echo "Checking drive..." | |
if ! [ -d "$DRIVE_PATH" ]; then | |
echo "Backup drive not mounted" | |
exit 1 | |
fi | |
echo "About to create home folder backup for $USER@$(hostname)..." | |
if ! [ -d "$BACKUP_PATH" ]; then | |
echo "Creating backup destination folder..." | |
mkdir -p $BACKUP_PATH | |
fi | |
if rdiff-backup /home/$USER $BACKUP_PATH >/dev/null 2>&1; then | |
echo "Done" | |
else | |
echo "An error occurred with rdiff-backup" | |
exit 1 | |
fi | |
else | |
echo "rdiff-backup is not installed, it is required" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment