Snap snapshot backup & restore
Nextcloud snap Backup, restore & migrate
A good backup strategy will enable data recovery in the case of disaster. Not having a backup makes a bad situation worse. There is nothing anyone can do if you don’t backup your data. So depending on your backup frequency and how often you practice restoring your backup, you’ll have a good chance of system recovery within a couple of hours with limited data loss. See backup, restore & migrate Nextcloud snap.
Depending on the type of failure, there is a good chance of recovering your raw data. By default all the stuff you care about is in the /var/snap/nextcloud directory. So just copy the entire directory to another drive (or machine). In the worst case you lose your database, but at least you’ll preserve your raw data. Your raw data can be found in /var/snap/nextcloud/common/nextcloud/data if you haven’t changed your data directory.
Snap snapshot is a snap utility to create and manage snap snapshots. It may be used for random snapshots or automated as scripted cronjob and has the added convenience of easy snap migration.
Snap snapshots official documentation
Example rotating backup script by @scubamuc
Example backup script by @sbe-arg
Backup Nextcloud snap with snap snapshot
Snap snapshot will backup the entire Nextcloud snap including configuration, apps, certificates, database and data into a compressed file (*.zip) located in /var/lib/snapd/snapshots. See what’s inside a snapshot.
See documentation in man snap and snap snapshot documentation
Backup procedure
- stop Nextcloud snap
sudo snap stop nextcloud - save Nextcloud snap
sudo snap save nextcloud - start Nextcloud snap
sudo snap start nextcloud - copy/move snapshot (*.zip) in
/var/lib/snapd/snapshotsto wherever
Restore or migrate Nextcloud snap with snap restore
Restore or migration procedure
- copy/move snapshot (*.zip) to
/var/lib/snapd/snapshots - discover snapshot-id using
snap saved - restore snapshot
sudo snap restore <snapshot-id>
MPORTANT
- When migrating be sure that Nextcloud snap is installed on the target device.
- Snap restore restores the entire Nextcloud snap including configuration, apps, certificates, database and data.
- CAUTION!: snap restore is not incremental and will completely replace existing installation.
See documentation in man snap and snap snapshot documentation
Deleting snap snapshots
See documentation in man snap and snap snapshot documentation
- discover snapshot-id using
sudo snap saved - delete snapshot
sudo snap forget <snapshot-id>
How to export and import Nextcloud snap
See Export & import