Last active
June 11, 2019 00:04
-
-
Save ftclausen/c9e0d5b34e7c4c5030fdde1c450731fc to your computer and use it in GitHub Desktop.
restic_wrapper.sh
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 | |
# Friedrich "Fred" Clausen - [email protected] | |
source_directories=("/var/tmp/inc_test" "/var/tmp/inc test 2") | |
remote="sftp:md:tmp/inc_test" | |
passwd="/tmp/pw" | |
report_location="/tmp" | |
log="$(mktemp -t backup_report_)" | |
sftp_log="$(mktemp)" | |
trap "{ echo \"Cleaning up...\"; rm -f \"$log\" \"$sftp_log\"; }" SIGINT SIGTERM EXIT INT | |
for dir in ${!source_directories[@]}; do | |
restic -r "$remote" backup --password-file "$passwd" "${source_directories[dir]}" 2>&1 | tee -a "$log" | |
done | |
restic -r "$remote" --password-file "$passwd" prune 2>&1 | tee -a "$log" | |
cat <<EOF &> "$sftp_log" | |
lcd ${log%/*} | |
cd $report_location/ | |
put ${log##*/} | |
EOF | |
remote_host=$(echo $remote | awk -F ':' '{print $2}') | |
sftp -b "$sftp_log" $remote_host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment