Scripts for backup/restore

hi,
just want to say thanks.

take your scripts - reworked them to use it with docker installation in the omv forums :wink:
so here is the link :wink:
omv forum - Nextcloud Docker Backup with DB
i also crosslink this post there.

maybe you can need the improvement of getting some needed values from the config.php file :wink:

thx again,
draddy

hi,
is it possible to backup/restore a specific user incl. his data?

No, this a always a full backup/restore.
The data belonging to one user is scattered in the data dir and the database. That would be a whole lot of (manual) work.

thank you
:raising_hand_man:

HI, Thanks for this awesome code.

Would you have some explanation on how to run the script when using openmediavault and docker/portainer to run the nextcloud instance? What does it change to your todo list?

Thanks,

Hi,

the script has to be run in the same machine as the NC instance. So, my first guess would be to include it somehow in the docker container itself.
But there I don’t have any experience as I’m running my NC instances without Docker.

Best regards,
Jan

I think for smaler installation you can use “tar” within the script.
But what about with bigger installation?
Perhaps you can better use “rsync” with “–link-dest” for incremental backups.

Indeed, I’ll pack the output in a borg backup repository. This way, the deduplicating really works great and the backups remain pretty small (depends on how many files have changed between two backup runs).

1 Like

I’m curious about this too, because when running Nextcloud in docker from Rancher if I stop the web server it kills the container. So I have not been stopping the web server when testing updates from 14 --> 15, and 15 --> 16.

I think you could backup and restore a single user without the information from the database, but you would have to php occ file:scan USERNAME after the restore to make sure the files showed up.

That is true when it comes to files only. Other information which is stored in the database only will possibly get lost.

Yes, that’s a very valid point.

I’ve just updated the scripts.

One new feature was added:
The scripts for backup/restore can now be initialized by a “setup script”. By running setup.sh, some information are gathered (user input) and all the other variables are obtained using OCC.

This way it should be much easier to install these scripts so that they fit to your Nextcloud installation.

However, you should never rely on the setup script. Always check the backup/restore scripts (line by line) before running these for the first time.

You can find the updated scripts here:

Feedback is much appreciated.

1 Like

Amazing script! I only have one problem: I cant locate the web server name! Sorry if its a silly question but i m new to all of these. I have to add i ve installed nextcloud 19 through snap.

apache2 or nginx? Which operation system?

i ve installed nextcloud 19 through snap.

I think the script is not for snap.

linux mint 19.3 xfce. I really don’t know which one, both “cant be found” through systemctl.
It does work with my snap installation since ive edited the script to point to the right directories.

thts the output when i run it:

Backup directory: /dev/Backups 2/NEXTCLOUD_BACKUP
Set maintenance mode for Nextcloud…
sudo: php: command not found
Done

Stopping web server…
Failed to stop nginx.service: Unit nginx.service not loaded.
Done

Creating backup of Nextcloud file directory…
Done

Creating backup of Nextcloud data directory…
Ignoring updater backup directory

So i guess it also doesnt put the server in maintanance mode…

You find normally the apache2-servername in the virtual hosts configurations.

/etc/apache2/sites-available/
/etc/apache2/sites-enabled (links to other dir)

Sorry. I do not use Snap and do not like it.
I thought Mint does not use it anymore.
Sorry german: https://www.heise.de/news/Linux-Mint-20-Desktop-ohne-Snap-Pakete-4797111.html
Please read for further help:

SNAP Installation change php, apache and nextcloud configs

Yes, the scripts are for a “standalone” installation of Nextcloud only. With Snap you have a ready to use package which is “all in one”. I don’t have any experience with Snap, but I guess that you have to back up the whole Snap package.
I think you cannot use these scripts for this task.

@giorgis1987

Linux Mint:
If linux mint, please do not use snap
https://www.omgubuntu.co.uk/2020/06/enable-snap-apps-linux-mint-20
Please use Ubunut LTS or Debian (server) versions an not the desktop releases of mint.
Mint is not a good idea for a server service like nextcloud.

If you want to install nextcloud on your desktop:
Install Ubunutu LTS or Debian Buster on your desktop and not mint.