Bash script for backing up data to Glacier with Duplicity and GPG encryption
25 lines
815 B
Bash
25 lines
815 B
Bash
#!/bin/bash
|
|
source .rgs3-configrc
|
|
|
|
currently_backuping=$(ps -ef | grep duplicity | grep python | wc -l)
|
|
|
|
if [ $currently_backuping -eq 0 ]; then
|
|
# Clear the recent log file
|
|
cat /dev/null > ${LOGFILE_RECENT}
|
|
|
|
log ">>> removing old backups"
|
|
duplicity remove-older-than ${KEEP_BACKUP_TIME} ${GS3_BUCKET} >> ${LOGFILE_RECENT} 2>&1
|
|
|
|
log ">>> creating and uploading backup to S3 Glacier storage"
|
|
duplicity \
|
|
incr --full-if-older-than ${FULL_BACKUP_TIME} \
|
|
--asynchronous-upload \
|
|
--archive-dir /dir/duplicity/cache/duplicity \
|
|
--s3-use-glacier \
|
|
--encrypt-key=${GPG_FINGERPRINT} \
|
|
--sign-key=${GPG_FINGERPRINT} \
|
|
${SOURCE} ${GS3_BUCKET} >> ${LOGFILE_RECENT} 2>&1
|
|
|
|
cat ${LOGFILE_RECENT} >> ${LOGFILE}
|
|
fi
|