Skip to content

Instantly share code, notes, and snippets.

@dojoe
Created December 26, 2024 13:52
Show Gist options
  • Save dojoe/eb690701b6e10b30b5e6db46e35715df to your computer and use it in GitHub Desktop.
Save dojoe/eb690701b6e10b30b5e6db46e35715df to your computer and use it in GitHub Desktop.
NextCloud backup using restic
#!/bin/bash
MYDIR=$(readlink -f $(dirname $0))
$MYDIR/occ maintenance:mode --on
docker container exec nextcloud-db mysqldump --single-transaction --default-character-set=utf8mb4 -u nextcloud -p<db password> nextcloud > /var/nextcloud/nextcloud-db.dump
RESTIC_PASSWORD=<repo password> $MYDIR/restic -r <repo URL> backup /root/compose/nextcloud /var/nextcloud/nextcloud-db.dump /var/nextcloud/site/{data,themes,config}
rm /var/nextcloud/nextcloud-db.dump
$MYDIR/occ maintenance:mode --off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment