How to clone a NC installation?


I’m looking for something like Debian:
dpkg --get-selections > deb.list
dpkg --set-selections < deb.list
apt-get dselect-upgrade

for NC (dump/restore configuration)

I have found that it’s not enough copy config.php (and db)
I imagine:
sudo -u www-data php ./occ app:list:available
sudo -u www-data php ./occ app:list:installed > app.list.txt
sudo -u www-data php ./occ app:enable < app.list.txt

I have found this after re-unzip in an already installed (and working) NC
mv nextcloud nextcloud.old;
cp nextcloud.old/config/config.php nextcloud/config/
cd nextcloud
sudo -u www-data php ./occ maintenance:update:htaccess

apps weren’t installed.

Do I miss something?

Thank you.

The nextcloud/apps folder? But you should of course not replace the new core apps with the old ones, just the additional installed apps that do not replace something new.

Ciao @MichaIng
so, this should works (from the FileSystem point of view, for Database -> usual dump/restore)
mv nextcloud nextcloud.old
cp nextcloud.old/config/config.php nextcloud/config/
cd nextcloud
rsync -au …/nextcloud.old/apps/ apps/
sudo -u www-data php ./occ maintenance:update:htaccess

cd …
diff -r nextcloud.12.1 nextcloud
Only in nextcloud: data

and with all Notes and Desk and Task …


Thank you!

1 Like

Could make a howto out of it :slight_smile:. Does "rsync -u " also leaves out newer folders, or only files? Otherwise theoretically newly removed core apps files could be copied over and produce integrity check errors.

From the man page:
-u "… Note that this does not affect the copying of dirs, symlinks, or other special files."
IF there are files and dirs in apps/ directory, this means that that app are installed (presents also into the DB)
The apps in nc.old should have older date/time (or at least the same) than the one in nc (new) so they are not copied into the new installation.
So the rsync command should be safe.

I mean it could happen, that developers remove one/some apps files inside the related apps subfolder during updates. As in this case, no newer file remains in the new nextcloud/apps/subfolder, but none, the old file would be copied in place again (this was my question). The new old file should just be ignored by nextcloud/the app, so should not be any harm, but the integrity check would recognize an extra file and besides the message refuse updates via web updater e.g.

The cases for this will be rare, so in your case, everything will be fine (and anyway easy to solve), but before putting the steps into a howto, it should be still resolved :wink: .

It took a while to understand the misunderstanding… :slight_smile:
My original question was about to clone a NC installation between 2 different server or same server and different setup, but THE SAME VERSION.
“old” and “new” were relative to installed / to install (again)
As you pointed out, default apps can change between different version.

1 Like

could you provide more notes / explanation on your commands?
Im just trying to rescue / clone my old nextcloud installation as written here:

any help appreciated!

It’s depend a lot on which problem you have with the “old” installation.
db corruption?
filesystem corruption?
php file damaged?

if you want just clone or backup yout NC installation

  1. db -> mysqldump --opt -Q -c -C > /mnt/backup/NC/nextcloud.sql
  2. filesystem -> rsync -auP /var/www/nextcloud /mnt/backup/NC/
  3. data dir -> rsync -auP /var/www/nextcloud-data /mnt/backup/NC/