Scripts for backup/restore

I’ve introduced a versioning of the scripts now. The version can be found in the header of the scripts. I think, now it’s easier to update already used scripts when some changes were made in the GitHub repo.

Also, v1.0.0 comes with some changes improving the maintainability.

You can also download an archive from the release page: https://github.com/DecaTec/Nextcloud-Backup-Restore/releases

1 Like

I’ve moved from GitHub to Codeberg.
You can find the repository with the scripts here:

Sir if I change your script and change nginx to apache2 its everything will be ok?

Nice script! Thank you very much.
Just one question (maybe i dont get it right)
why do you need to stop the webserver during the backup?
isnt it enough to put it to maintenance mode?
i mean now my clients wont get the information that the server is in maintenance right now because the webserver is not running?

bests,
Matthias

Hello Matthias,

it should work when the webserver is still running and only the maintenance mode of NC is active.
However, I do stop the webserver in order to make absolutely sure that there are no activities in NC.

When your concern is regarding other web applications running on the same server, you could also disable the virtual host for NC and reload the webserver config. This makes sure that no other web application will become unavailable while the backup of NC is running.

Best regards,
Jan

OK, i removed the stop/start of the webserver from the script.

my concern is that the nextcloud-clients (for example my brother who is using my server doesnt get the “maintenance/backup in progress” notice when i stop the webserver. so for the user out there it looks like a problem.

and a suggestion/small improvement

i added the “-I pigz” option to the tar call to enable parallel gzip

tar -I pigz -cpf "${backupdir}/${fileNameBackupFileDir}" -C "${nextcloudFileDir}" .

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.

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.