Skip to content

Instantly share code, notes, and snippets.

@reox
Created March 28, 2016 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/3f006ad3e09cf35a027f to your computer and use it in GitHub Desktop.
Save reox/3f006ad3e09cf35a027f to your computer and use it in GitHub Desktop.
Bup Backup using a remote BUP_DIR
#!/bin/bash
# creake a backup of several folders using bup
# Using $TARGET as $BUP_DIR
TARGET=/mnt/backup
FOLDERS="/etc /root /home /srv /var"
LOGFILE="$TARGET/logs/$(date +%Y%m%d_%H%M%S).log"
(
flock -n 200
echo "Bup index..." | tee -a $LOGFILE
BUP_DIR=$TARGET bup index -ux $FOLDERS 2>&1 | tee -a $LOGFILE
echo "Bup Save..." | tee -a $LOGFILE
BUP_DIR=$TARGET bup save -n ceali $FOLDERS 2>&1 | tee -a $LOGFILE
find $TARGET/logs -mtime +7 -exec rm {} \;
) 200>/root/.backupinprogress
@reox
Copy link
Author

reox commented Mar 28, 2016

or using a remote target:

#!/bin/bash
FOLDERS="/etc /root /home /srv /var"
LOGFILE="/tmp/bup_backup_$(date +%Y%m%d_%H%M%S).log"
(
        flock -n 200
        echo "Bup index..." | tee -a $LOGFILE
        bup index -u $FOLDERS 

        echo "Bup Save..." | tee -a $LOGFILE
        bup save -r remote.host.tld:/var/bup/backupfolder -n servername $FOLDERS 

) 200>/root/.backupinprogress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment