Created
December 18, 2011 17:31
-
-
Save epochblue/1493995 to your computer and use it in GitHub Desktop.
The backup script I use to backup the data I care about.
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 | |
| # backup -- a time waster by Bill Israel | |
| # | |
| # The backup script I use to backup the data I care about. | |
| # Is run daily via cron. | |
| # Must have remote folder param | |
| [ -z "$1" ] && echo -e "usage: $0 REMOTE_FOLDER\n" && exit 1 | |
| BASE_FOLDER="$HOME/" | |
| FOLDERS=( "Music" "Pictures" "Documents" "Downloads" "src" ) | |
| # Add a trailing slash if there isn't one | |
| [[ $1 != */ ]] && REMOTE_FOLDER="$1/" || REMOTE_FOLDER="$1" | |
| # Ensure remote folder exists | |
| if [ ! -d "$REMOTE_FOLDER" ]; then | |
| echo "$REMOTE_FOLDER doesn't exist. Creating it." | |
| mkdir $REMOTE_FOLDER | |
| fi | |
| # Back that ass up | |
| for folder in ${FOLDERS[@]}; do | |
| FROM="${BASE_FOLDER}${folder}/" | |
| TO="${REMOTE_FOLDER}${folder}/" | |
| echo -e "\n[`date`] Backing up $FROM to $TO\n" | |
| rsync -vax --delete --ignore-errors "$FROM" "$TO" | |
| done | |
| echo -e "\n\nBackup completed `date`.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment