The Nextcloud snap contains a utility nextcloud.export that automatically makes a copy of the Nextcloud instance. By default, the export location is /var/snap/nextcloud/common/backups/20190121-153921, where the date is the current date, as explained here:
This utility doesnât offer a way to change the export directory, and I am trying to come up with a good workaround. For illustration purposes, letâs suppose I want to use /home/fun/nextcloud_backups/ as my backup directory instead.
My idea was to make /var/snap/nextcloud/common/backups/ into a symlink to my desired backup directory:
$ sudo -i
# mkdir /home/fun/nextcloud_backups/
# ln -s /home/fun/nextcloud_backups/ /var/snap/nextcloud/common/backups
(Note that at the time I ran these commands, I hadnât used nextcloud.export, so the /var/snap/nextcloud/common/backups directory does not yet exist.)
However, trying to export gives me the following permissions error:
# nextcloud.export
WARNING: This functionality is still experimental and under
development, use at your own risk. Note that the CLI interface is
unstable, so beware if using from within scripts.
mkdir: cannot create directory '/var/snap/nextcloud/common/backups': Permission denied
chmod: cannot access '/var/snap/nextcloud/common/backups/20220808-024447': Permission denied
/snap/nextcloud/31222/bin/export-data: 134: /snap/nextcloud/31222/bin/export-data: cannot create /var/snap/nextcloud/common/backups/20220808-024447/format: Permission denied
Enabling maintenance mode... done
Exporting apps...
rsync: ERROR: cannot stat destination "/var/snap/nextcloud/common/backups/20220808-024447/apps": Permission denied (13)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(653) [Receiver=3.1.2]
Unable to export apps
Disabling maintenance mode... done
How do I give the Nextcloud snap permission to follow this symlink? Or is there a better way to change the export location?
- Ultimately, my goal is to store the backups on a separate (internal) hard drive, and set up a cron job that does this on a weekly basis, so if my boot drive gets corrupted, I can wipe it, reinstall Nextcloud, and restore my instance from the other drive.
- Therefore, using the export the utility as-is and then
mving the exported directory doesnât solve my problem, because it will require copying and then moving all of my Nextcloud data as opposed to just copying it once.