# How to clone a NC installation?

**URL:** <https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935>\
**Category:** ℹ️ Support\
**Created:** [August 22, 2017, 12:34pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935 "2017-08-22T12:34:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![paolo-pedaletti](https://help.nextcloud.com/user_avatar/help.nextcloud.com/paolo-pedaletti/32/1343_2.png) [@paolo-pedaletti](https://help.nextcloud.com/u/paolo-pedaletti)\
**Post date:** [August 22, 2017, 12:34pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/1 "2017-08-22T12:34:54Z")

</div>

Ciao,

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 latest-12.zip in an already installed (and working) NC  
mv nextcloud nextcloud.old;  
unzip latest-12.zip  
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.

---

<div class="post-metadata">

**Author:** ![MichaIng](https://help.nextcloud.com/user_avatar/help.nextcloud.com/michaing/32/2125_2.png) [@MichaIng](https://help.nextcloud.com/u/MichaIng)\
**Post date:** [August 22, 2017, 1:44pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/2 "2017-08-22T13:44:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paolo-pedaletti](https://help.nextcloud.com/user_avatar/help.nextcloud.com/paolo-pedaletti/32/1343_2.png) [@paolo-pedaletti](https://help.nextcloud.com/u/paolo-pedaletti)\
**Post date:** [August 22, 2017, 2:32pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/3 "2017-08-22T14:32:56Z")

</div>

Ciao @MichaIng  
so, this should works (from the FileSystem point of view, for Database -\> usual dump/restore)  
mv nextcloud nextcloud.old  
unzip latest-12.zip  
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!

---

<div class="post-metadata">

**Author:** ![MichaIng](https://help.nextcloud.com/user_avatar/help.nextcloud.com/michaing/32/2125_2.png) [@MichaIng](https://help.nextcloud.com/u/MichaIng)\
**Post date:** [August 24, 2017, 6:01pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/4 "2017-08-24T18:01:38Z")

</div>

Could make a howto out of it 🙂. 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.

---

<div class="post-metadata">

**Author:** ![paolo-pedaletti](https://help.nextcloud.com/user_avatar/help.nextcloud.com/paolo-pedaletti/32/1343_2.png) [@paolo-pedaletti](https://help.nextcloud.com/u/paolo-pedaletti)\
**Post date:** [August 25, 2017, 12:40pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/5 "2017-08-25T12:40:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MichaIng](https://help.nextcloud.com/user_avatar/help.nextcloud.com/michaing/32/2125_2.png) [@MichaIng](https://help.nextcloud.com/u/MichaIng)\
**Post date:** [August 25, 2017, 3:21pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/6 "2017-08-25T15:21:46Z")

</div>

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 😉 .

---

<div class="post-metadata">

**Author:** ![paolo-pedaletti](https://help.nextcloud.com/user_avatar/help.nextcloud.com/paolo-pedaletti/32/1343_2.png) [@paolo-pedaletti](https://help.nextcloud.com/u/paolo-pedaletti)\
**Post date:** [August 29, 2017, 10:28pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/7 "2017-08-29T22:28:06Z")

</div>

It took a while to understand the misunderstanding… 🙂  
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.

---

<div class="post-metadata">

**Author:** ![dred](https://help.nextcloud.com/letter_avatar/dred/32/5_5575768a8748004e209b776fc1b2916d.png) [@dred](https://help.nextcloud.com/u/dred)\
**Post date:** [September 2, 2017, 6:49am UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/8 "2017-09-02T06:49:09Z")

</div>

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

> [@Nextcloud migration from dead server](https://help.nextcloud.com/t/nextcloud-migration-from-dead-server/19923/2):
>
> I guess all hard drives of the old server are still running, so you have access to the nextcloud folder, data folder and theoretically database, which was also mysql/mariadb before? So the nextcloud and data folders can just copied over. To set nextcloud into maintenance, you can manually change the related line in you nextcloud/config/config.php before accessing nc on your new machine. About the database I am not too sure how to get all that data inside safely to your new machine, as you cann…

any help appreciated!

---

<div class="post-metadata">

**Author:** ![paolo-pedaletti](https://help.nextcloud.com/user_avatar/help.nextcloud.com/paolo-pedaletti/32/1343_2.png) [@paolo-pedaletti](https://help.nextcloud.com/u/paolo-pedaletti)\
**Post date:** [September 5, 2017, 2:20pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/9 "2017-09-05T14:20:37Z")

</div>

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/

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [September 23, 2024, 6:13pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/10 "2024-09-23T18:13:12Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 1:32pm UTC](https://help.nextcloud.com/t/how-to-clone-a-nc-installation/19935/11 "2024-12-09T13:32:41Z")

</div>


