Skip to content

Instantly share code, notes, and snippets.

@billimek
Created November 19, 2020 12:55
Show Gist options
  • Save billimek/dec98675dbbb0ed5c12512d3ec734190 to your computer and use it in GitHub Desktop.
Save billimek/dec98675dbbb0ed5c12512d3ec734190 to your computer and use it in GitHub Desktop.
rclone/borg backups to backblaze b2
[Unit]
Description=Sync files using rclone
[Service]
Type=oneshot
User=root
ExecStart=/root/backup/rclone_borg_sync.sh
[Unit]
Description=Perform an rclone sync periodically.
Requires=rclone-sync.service
[Timer]
OnCalendar=07:00
RandomizedDelaySec=60
[Install]
WantedBy=timers.target
#!/bin/bash
set -e
repos=( lb pihole proxmox proxmox-b proxmox-c home )
#Bail if rclone is already running, maybe previous run didn't finish
if pidof -x rclone >/dev/null; then
echo "Process already running"
# exit
fi
for i in "${repos[@]}"
do
#Lets see how much space is used by directory to back up
#if directory is gone, or has gotten small, we will exit
space=`du -s /tank/backups/borg/$i|awk '{print $1}'`
if (( $space < 4500 )); then
echo "not enough space used in $i ($space) - skipping!"
else
echo "==================== syncing $i"
/usr/bin/rclone --config /root/.config/rclone/rclone.conf -v sync /tank/backups/borg/$i b2-borg:/billimek-borg/$i
fi
done
echo "==================== syncing RESTIC backups"
restic_repos=( default monitoring )
for i in "${restic_repos[@]}"
do
echo "==================== syncing $i"
/usr/bin/rclone --config /root/.config/rclone/rclone.conf -v sync /tank/data/minio/velero/restic/$i b2-restic:/billimek-restic/restic/$i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment