How To Backup A NextCloud Snap Installation On Linux

Nextcloud truly is the software of the future. Thanks to it, it’s simpler than ever to spin up your own user-friendly, Dropbox-like storage solution on Linux. Setup for the software is extremely easy thanks to things like Snap packages. However it isn’t as easy to backup a NextCloud Snap installation.

Note: Before doing a Nextcloud backup, ensure the entirety of your files has finished syncing. During the backup process, the NextCloud snap will shut off, suspending all services to all users connected to it.

Stop The Server

Creating a backup of Nextcloud, especially the Snap version, requires the suspension of the server software. Without turning the Nextcloud server off, certain files may fail to save, permission errors could arise, and even data could be lost.

Luckily, suspending a running Nextcloud server is just about as easy as installing it! To stop the server, open up a terminal and gain a root shell using su or sudo -s. Then, use the snap stop command to stop all Nextcloud services.

su -

or

sudo -s
snap stop nextcloud

Running the snap stop command will disable the SQL database, and other running Nextcloud services. It will not uninstall them, so don’t worry! Your files are safe!

RECOMMENDED FOR YOU

Back Up Folders

With the server temporarily shut off, it’s safe to create a backup of Nextcloud. However, before the server-side backup can begin, we recommend creating a backup of the ~/Nextcloud folder for each user. This way, if anything happens to the server backup, users will still have a duplicate of their data.

To create a backup of a Nextcloud sync folder, go to any Linux PC that uses the sync server, and open up a terminal. In the terminal, use the Tar command to create an archive of the ~/Nextcloud folder. Be sure to replace “username” in the command below with your username.

tar -zcvpf nextcloud-local-backup-username.tar.gz ~/Nexcloud

Depending on how large ~/Nextcloud is, the compression process may take a while. When the archiving process is complete, use the GPG command to encrypt the archive (for security purposes.)

After GPG finishes the encryption process, place the encrypted backup somewhere safe.

Back Up Nextcloud

Backing up the Snap version of Nextcloud is by far the easiest, compared to the traditional Nextcloud setup. Since everything is in the Nextcloud Snap folder, there’s no need to export any SQL databases or mess with individual files. Instead, users can create a complete backup of Nextcloud by making a copy of two individual folders.

The first folder to backup within the Nextcloud Snap directory is the configuration directory. To determine the name of the Nextcloud config folder, run lsblk and see where it is on the system. As of writing this article, the mount folder is:

/var/lib/snapd/snap/nextcloud/7658

Make a new backup folder inside of /home/username/ with the mkdir command and use the cp command to copy everything to it.