Backing up FreeNAS Nextcloud plugin

Status
Not open for further replies.

gsk3

Cadet
Joined
Sep 12, 2017
Messages
5
Have been unable to find a decent guide to backing up my FreeNAS Nextcloud jail's data. I basically have a stock plugin.

The Nextcloud docs seem simple but are incomplete and confusing (https://docs.nextcloud.com/server/11/admin_manual/maintenance/backup.html).

Do the "config, data and theme folders" refer to everything in the web root? If so, /usr/local/www/nextcloud doesn't have a data folder. The config folder therein contains "config.sample.php" not "config.php". The folder /usr/pbi/nextcloud-amd64/www/nextcloud/config does have a config.php, but the PBI in the path implies this was the install folder not the active folder right? On second glance, it also has a data folder and a log, so perhaps this is the active folder to backup?

Inside the jail, I find:
root@nextcloud_1:/# find / -name nextcloud
/var/db/mysql/nextcloud
/usr/pbi/nextcloud-amd64/www/nextcloud
/usr/local/www/nextcloud

Asking here rather than Nextcloud forum because I suspect the answer will be different for the plugin default locations.

Once I find it will install rclone and backup to Backblaze B2.

Thanks!
 

Allan Wilmath

Explorer
Joined
Nov 26, 2015
Messages
99
There are a numbers ways, the first is to simply set up automatic snapshots on the jail. Another is to use rsync to a backup location using the -a to preserve the file permissions. Preserving file permissions are very important. You can use SSH from within the jail, and push the backup, or enable SSH in the jail and pull the backup in the FreeNAS rsync page. You can also run the rsync from outside of the jail as root, don't forget to use the -a to preserver permissions.

You could also create a compressed archive file. You can google how to make an archive with something like gzip.
 

gsk3

Cadet
Joined
Sep 12, 2017
Messages
5
Thanks for the suggestions. I'd rather not back up the whole snapshot, but rather the data (preferably in a format that will let me access the raw files if Nextcloud were to disappear tomorrow or I can't replicate the setup I had previously--trying to avoid format rot for some important files.

Just to clarify, I know how to set up backups. What I need to know is which files in the FreeNAS Nextcloud plugin's jail I need to be backing up.

Thanks!
 

DazB

Cadet
Joined
Jan 8, 2018
Messages
4
Thanks for the suggestions. I'd rather not back up the whole snapshot, but rather the data (preferably in a format that will let me access the raw files if Nextcloud were to disappear tomorrow or I can't replicate the setup I had previously--trying to avoid format rot for some important files.

Just to clarify, I know how to set up backups. What I need to know is which files in the FreeNAS Nextcloud plugin's jail I need to be backing up.

Thanks!

Hi gsk3! Did you manage to find a solution to this? I also want to back up my NextCloud plugin, ideally in a way to restore the whole thing easily (i.e. database, users, data etc.) in the event I have to reinstall FreeNAS, but haven't found a clear answer how to do this.

Any help would be really appreciated
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
There are a number of better ways to use Nextcloud than the plugin (insert shameless plug for https://github.com/danb35/freenas-iocage-nextcloud). But whichever way you use it, the important thing is to back up the data directory and the database. The data itself, barring use of encryption, is stored in clear text in the data directory, in subdirectories for each user. The location of that directory will vary with the installation method, but probably the easiest way to find it is to see what the config file says. To find that, from inside the jail, run find / -name config.php.

Backing up the database is going to depend on the database backend in use--at one point, I think the plugin was using SQLite, which strikes me as a very poor choice for any but the most trivial installations. If it's using mysql, the mysqldump command will do the job. If MySQL is set up sensibly (i.e., the root user's password is saved in /root/.my.cnf), you can do this by simply running mysqldump nextcloud > file.sql (replacing file.sql with whatever filename you want). If MySQL isn't set up sensibly, you can find the password for the nextcloud database user in the config file and run mysqldump -u nextcloud -p nextcloud > file.sql, and then enter the password when it prompts you.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
There are a number of better ways to use Nextcloud than the plugin (insert shameless plug for https://github.com/danb35/freenas-iocage-nextcloud). But whichever way you use it, the important thing is to back up the data directory and the database. The data itself, barring use of encryption, is stored in clear text in the data directory, in subdirectories for each user. The location of that directory will vary with the installation method, but probably the easiest way to find it is to see what the config file says. To find that, from inside the jail, run find / -name config.php.

Backing up the database is going to depend on the database backend in use--at one point, I think the plugin was using SQLite, which strikes me as a very poor choice for any but the most trivial installations. If it's using mysql, the mysqldump command will do the job. If MySQL is set up sensibly (i.e., the root user's password is saved in /root/.my.cnf), you can do this by simply running mysqldump nextcloud > file.sql (replacing file.sql with whatever filename you want). If MySQL isn't set up sensibly, you can find the password for the nextcloud database user in the config file and run mysqldump -u nextcloud -p nextcloud > file.sql, and then enter the password when it prompts you.

On a similar note if you want to restore nextcloud to a new server you would?
1)import the file.sql dump into the new nextcloud install
2) copy all the contents of the old /mnt/files directory to the new /mnt files directory
3) can't copy the config.php to the new install. You have redo the email settings and others manually?
Do I have that right?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
can't copy the config.php to the new install.
Not sure why not, but you'd definitely want to make sure the paths and such are right. Other than that, it sounds like that should work.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
Seems to be working.
cp -r /mnt/POOL_NAME/OLD_FILES/* /mnt/POOL_NAME/NEW_FILES/

in Jail
mysql -u DB_USER_NAME -p DATABASE_NAME < DBBACKUP.sql
service mysql-server restart
 
Status
Not open for further replies.
Top