# Migrate Nextcloud snap installation from one VPS to another

**URL:** <https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297>\
**Category:** ℹ️ Support\
**Tags:** snap\
**Created:** [June 21, 2020, 11:44am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297 "2020-06-21T11:44:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mabkenar](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mabkenar/32/2446_2.png) [@mabkenar](https://help.nextcloud.com/u/mabkenar)\
**Post date:** [June 21, 2020, 11:44am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/1 "2020-06-21T11:44:43Z")

</div>

I have my personal Nextcloud server installed on a DigitalOcean Droplet. I use the official snap package from [snapcraft.io/nextcloud](http://snapcraft.io/nextcloud) (sources in [https://github.com/nextcloud/nextcloud-snap/](https://github.com/nextcloud/nextcloud-snap/)) by @kyrofa (thanks as always 😀💙). I mean, the whole installation process was `snap install nextcloud` and a few other commands (configuring Let’s Encrypt and installing a TURN server `(coturn)` via apt).

For various reasons, I want to migrate my **Nextcloud installation to a new VPS, I mean a completely new hosting provider**. How can I achieve that as seamless as possible?

I haven’t been able to find a guide to **migrate a server snap from one host to the other** , neither for Nextcloud snap specifically, nor generally for any snap. Can anyone please help me or point me to a relevant documentation?

---

<div class="post-metadata">

**Author:** ![kyrofa](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kyrofa/32/6500_2.png) [@kyrofa](https://help.nextcloud.com/u/kyrofa)\
**Post date:** [June 21, 2020, 10:01pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/2 "2020-06-21T22:01:31Z")

</div>

Honestly, the answer is “it depends.” I know, terrible answer.

It depends on how your data is stored. If you haven’t moved your data from the default location, you should try using the `nextcloud.export` and `nextcloud.import` commands. If you have, those commands will export your database and stuff, but you’ll need to migrate the Nextcloud data dir by hand. That doesn’t include SSL certs and whatnot, you’ll need to configure those again, but it should cover most things. Don’t get rid of your existing install until you’ve verified everything looks good, of course.

---

<div class="post-metadata">

**Author:** ![mabkenar](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mabkenar/32/2446_2.png) [@mabkenar](https://help.nextcloud.com/u/mabkenar)\
**Post date:** [June 21, 2020, 10:07pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/3 "2020-06-21T22:07:19Z")

</div>

Perfect. Thank you dear Kyle! I was not aware of the `import` and `export` commands. No, I haven’t changed anything related to data location. So I guess it should work as you say. I will try it and will report my experience here. Let’s see how it goes 😀

---

<div class="post-metadata">

**Author:** ![kyrofa](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kyrofa/32/6500_2.png) [@kyrofa](https://help.nextcloud.com/u/kyrofa)\
**Post date:** [June 21, 2020, 10:08pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/4 "2020-06-21T22:08:15Z")

</div>

Please do. They’re not new commands, but they haven’t gotten a ton of mileage, so do please double check that everything looks okay, and please do let me know how it works!

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [June 22, 2020, 4:42am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/5 "2020-06-22T04:42:44Z")

</div>

Sorry, i do not like Snap. Without Snap you easily could use the backup/restore-documentation from Nextcloud.

---

<div class="post-metadata">

**Author:** ![mabkenar](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mabkenar/32/2446_2.png) [@mabkenar](https://help.nextcloud.com/u/mabkenar)\
**Post date:** [July 12, 2020, 9:46pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/6 "2020-07-12T21:46:32Z")

</div>

Hi again.

I tried it and still I have no success. First of all, there is the space problem. One of the reasons I am migrating to a new VPS is because I have run out of space in the current one. I cannot use `nextcloud.export -abcd` because my stored data is huge and I do not have enough space for another backup copy on the same machine. Therefore, I copied the data directory manually to the new server, and I only ran `nextcloud.export -abc` (without `d`). This worked.

However, after I copy the backup directory to the new VPS, and when I run `nextcloud.import -abc`, I get this error:

```auto
$ sudo nextcloud.import -abc backups/20200712-201609/
WARNING: This functionality is still experimental and under
development, use at your own risk. Note that the CLI interface is
unstable, so beware if using from within scripts.

Clearing existing non-default apps... done
Importing apps...
rsync: change_dir "/home/mabkenar//backups/20200712-201609/apps" failed: Permission denied (13)
              0 100% 0.00kB/s 0:00:00 (xfr#0, to-chk=0/0)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
Unable to import apps
Disabling maintenance mode... done

```

I have tried `sudo chown -R mabkenar:mabkenar backups/` to make sure permissions are done right. But it still gives the same error message.

I appreciate any help.

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [July 13, 2020, 5:51am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/7 "2020-07-13T05:51:07Z")

</div>

No idea. Perhaps you can ask in an Snap-forum.

---

<div class="post-metadata">

**Author:** ![kyrofa](https://help.nextcloud.com/user_avatar/help.nextcloud.com/kyrofa/32/6500_2.png) [@kyrofa](https://help.nextcloud.com/u/kyrofa)\
**Post date:** [July 13, 2020, 2:53pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/8 "2020-07-13T14:53:44Z")

</div>

> [@mabkenar](#):
>
> `rsync: change_dir "/home/mabkenar//backups/20200712-201609/apps" failed: Permission denied (13)`

The importer doesn’t have permission to access your home directory (due to confinement). Try putting your backups in /media somewhere and make sure the `removable-media` interface is connected.

---

<div class="post-metadata">

**Author:** ![mabkenar](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mabkenar/32/2446_2.png) [@mabkenar](https://help.nextcloud.com/u/mabkenar)\
**Post date:** [July 16, 2020, 11:06pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/9 "2020-07-16T23:06:30Z")

</div>

Yes. It finally worked 😀

What I did on the old server:

```bash
sudo apt autoremove #free up a little space for the backup
sudo apt clean #free up a little more!
sudo nextcloud.export -abc #backup apps, databse, and configs, but not files (since there was no space left on the server for duplicating all the files)

```

What I did on the new server:

```bash
sudo snap install nextcloud
scp -pr <username>@<old_VPS_IP_address>:/var/snap/nextcloud/common/ /var/snap/nextcloud/common/ #copy files directly from the old server to the new one
sudo scp -pr <username>@<old_VPS_IP_address>:/var/snap/nextcloud/common/backups /media/ #copy the backup (apps, database, and config) to the new server as well
sudo chown -R root:root /media/backups/ #make sure files belong to root
sudo snap connect nextcloud:removable-media :removable-media #give nextcloud permission to read /media directory
sudo nextcloud.import -abc /media/backups/<backup-date>/ #import the backup

```

And after all that, of course on the new server:

```auto
sudo nextcloud.enable-https lets-encrypt

```

---

<div class="post-metadata">

**Author:** ![ksl28](https://help.nextcloud.com/letter_avatar/ksl28/32/6_22734026db12803ebb3e059622ac3534.png) [@ksl28](https://help.nextcloud.com/u/ksl28)\
**Post date:** [January 6, 2021, 5:06pm UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/10 "2021-01-06T17:06:13Z")

</div>

> [@mabkenar](#):
>
> `sudo nextcloud.enable-https lets-encrypt`

That helped me alot! Thanks for sharing!

---

<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 12, 2024, 7:26am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/11 "2024-12-12T07:26:37Z")

</div>



---

<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 12, 2024, 7:26am UTC](https://help.nextcloud.com/t/migrate-nextcloud-snap-installation-from-one-vps-to-another/85297/12 "2024-12-12T07:26:39Z")

</div>


