Skip to content

Instantly share code, notes, and snippets.

@dado-prateek
Last active December 23, 2023 08:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dado-prateek/4f3edd911eb1e265e839 to your computer and use it in GitHub Desktop.
Save dado-prateek/4f3edd911eb1e265e839 to your computer and use it in GitHub Desktop.
Backup with duplicity to yandex.disk
#!/bin/sh
# Duplicity wrapper
#
# Not working for now. Yandex prevents uploading lagre files via webdav.
# add to crontab:
# 0 0 * * * /bin/sh /usr/local/sbin/backup-host.sh
set -e
PASSPHRASE="long_passphrase"
DISK_USER="login@yandex.ru"
DISK_PASSWORD=""
BACKUP_DIR=/
INCLUDES_EXCLUDES="\
--exclude '/home/*/Downloads' \
--exclude '/home/*/.cache' \
--exclude '/home/*/tmp' \
--exclude '/home/*/VirtualBox VMs' \
--exclude '/home/*/mnt' \
--exclude '/root/.cache' \
--exclude '/root/tmp' \
--include '/home' \
--include '/root' \
--include '/etc' \
--include '/srv' \
--include '/var' \
--exclude '**'"
DEST=webdavs://${DISK_USER}@webdav.yandex.ru/Backup/$(hostname)
export PASSPHRASE
export FTP_PASSWORD=${DISK_PASSWORD}
DUPLICITY_CMD="duplicity \
-v2 \
--ssl-cacert-file /etc/ssl/certs/ca-certificates.crt"
CLEAN_CMD="${DUPLICITY_CMD} \
remove-older-than 2M --force \
${DEST}"
BACKUP_CMD="${DUPLICITY_CMD} \
--full-if-older-than 1M \
${INCLUDES_EXCLUDES} \
${BACKUP_DIR} \
${DEST}"
VERIFY_CMD="${DUPLICITY_CMD} \
verify \
${INCLUDES_EXCLUDES} \
${DEST} \
${BACKUP_DIR}"
RESTORE_CMD="${DUPLICITY_CMD} \
${DEST} \
${PWD}"
echo ${CLEAN_CMD}; eval ${CLEAN_CMD}
echo ${BACKUP_CMD}; eval ${BACKUP_CMD}
echo ${VERIFY_CMD}; eval ${VERIFY_CMD}
# echo ${RESTORE_CMD}; eval ${RESTORE_CMD}
unset PASSPHRASE
unset FTP_PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment