Restoring a complete backup on a fresh install

Version française plus bas.

Currently my Yunohost is running on a Vorke V1 with 8Go RAM, and a 512Go hard drive.
However I want to virtualize my yunohost server, and run it on my ProxMox cluster.

So I created a VM, with 4Go RAM, and 650GB of disk space.

On the vorke V1, i mounted the VM drive using SSHFS, and then made a complete backup using the commands:

  • sshfs root@192.168.111.8:/home/yunohost.backup /home/yunohost.backup.nfs/
  • yunohost backup create -n test-20180721 -d “My comment” -o /home/yunohost.backup.nfs/

This backup ended successfully.

On the VM, I installed Debian 9.5 distrib, then installed Yunohost, and tried to restore the complete configuration using these simple commands:

  • mkdir /home/yunohost.backup/archives
  • mv /home/yunohost.backup/test-20180721.tar.gz /home/yunohost.backup/archives
  • yunohost backup restore test-20180721
    After few hours, I received the following message:

Traceback (most recent call last):
File “/usr/bin/yunohost”, line 213, in
timeout=opts.timeout,
File “/usr/lib/python2.7/dist-packages/moulinette/init.py”, line 136, in cli
moulinette.run(args, output_as=output_as, password=password, timeout=timeout)
File “/usr/lib/python2.7/dist-packages/moulinette/interfaces/cli.py”, line 390, in run
ret = self.actionsmap.process(args, timeout=timeout)
File “/usr/lib/python2.7/dist-packages/moulinette/actionsmap.py”, line 498, in process
return func(**arguments)
File “/usr/lib/moulinette/yunohost/backup.py”, line 2122, in backup_restore
restore_manager.mount()
File “/usr/lib/moulinette/yunohost/backup.py”, line 1025, in mount
self.method.mount(self)
File “/usr/lib/moulinette/yunohost/backup.py”, line 1868, in mount
tar.extractall(members=subdir_and_files, path=self.work_dir)
File “/usr/lib/python2.7/tarfile.py”, line 2081, in extractall
self.extract(tarinfo, path)
File “/usr/lib/python2.7/tarfile.py”, line 2118, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
File “/usr/lib/python2.7/tarfile.py”, line 2211, in _extract_member
self.utime(tarinfo, targetpath)
File “/usr/lib/python2.7/tarfile.py”, line 2332, in utime
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
OverflowError: Python int too large to convert to C long

It seems that the script created a new directory /home/yunohost.backup/tmp. This directory now contains 208GB of datas.
However, my server is still not restored and functionnal.

What can I do to restore my configuration on my VM using the “yunohost backup”/“yunohost restore” process ?

The applications installed are:

  • Nextcloud
  • Rainloop
  • OpenSondage
  • Shell in a box
  • PhpMyAdmin

No custom configuration done.

My YunoHost configuration

Internet access: Fiber 1GB
YunoHost version:
yunohost: latest version
yunohost-admin: latest version
moulinette: latest version
ssowat: latest version

Here’s the result of ‘df -h’:
/dev/mapper/VM–LCDR–NEW–vg-root 5,7G 2,2G 3,2G 40% /
/dev/sda1 236M 63M 162M 28% /boot
/dev/mapper/DATAS-HOME 536G 453G 57G 89% /home

and a ‘ls -thl’ in /home/yunohost.backup/archives,
root@VM-LCDR-NEW:/home/yunohost.backup/archives# ls -htl
total 246G
-rw-r–r-- 1 root root 246G juil. 21 19:29 test-20180721.tar.gz
-rw-r–r-- 1 root root 2,2K juil. 21 11:16 test-20180721.info.json

{
“host”: “Debian 9.5”,
“kernel”: “4.9.0-7-amd64”,
“packages”: {
“yunohost”: {
“repo”: “stable”,
“version”: “3.0.0.1”
},
“yunohost-admin”: {
“repo”: “stable”,
“version”: “3.0.0”
},
“moulinette”: {
“repo”: “stable”,
“version”: “3.0.0”
},
“ssowat”: {
“repo”: “stable”,
“version”: “3.0.0”
}
},
“backports”: ,
“system”: {},
“nginx”: [
“nginx: the configuration file /etc/nginx/nginx.conf syntax is ok”,
“nginx: configuration file /etc/nginx/nginx.conf test is successful”
],
“services”: {
“glances”: “exited (enabled)”,
“nslcd”: “running (enabled)”,
“metronome”: “running (enabled)”,
“postfix”: “exited (enabled)”,
“rspamd”: “running (enabled)”,
“yunohost-firewall”: “exited (enabled)”,
“dovecot”: “running (enabled)”,
“nginx”: “running (enabled)”,
“php7.0-fpm”: “running (enabled)”,
“dnsmasq”: “running (enabled)”,
“fail2ban”: “running (enabled)”,
“yunohost-api”: “running (enabled)”,
“mysql”: “running (enabled)”,
“avahi-daemon”: “running (enabled)”,
“shellinabox”: “running (enabled)”,
“redis-server”: “running (enabled)”,
“slapd”: “running (enabled)”,
“ssh”: “running (enabled)”
},
“applications”: {
“phpmyadmin”: “phpMyAdmin”,
“opensondage”: “OpenSondage”,
“rainloop”: “Rainloop”,
“shellinabox”: “Shell In A Box”,
“nextcloud”: “Nextcloud”
},
“security”: {
“CVE-2017-5754”: {
“name”: “meltdown”,
“vulnerable”: false
}
}
}

Actuellement, mon serveur fonctionne sur une machine Vorke V1 avec 8Go de disque, et un disque de 500Go.

Il me faut virtualiser cette fonfiguration.

J’ai construis une VM sur mon cluster ProxMox. Cette VM a 4Go RAM, et 650Go disque.

J’ai effectuée une sauvegarde de mon serveur directement sur ma VM via un montage SSFS.

Une fois la sauvegarde terminée, j’ai lancé la restoration de la config sur ma VM avec les commandes:

  • mkdir /home/yunohost.backup/archives
  • mv /home/yunohost.backup/test-20180721.tar.gz /home/yunohost.backup/archives
  • yunohost backup restore test-20180721

Au bout de quelques heures, j’obtiens le message ci-dessous:

Traceback (most recent call last):
File “/usr/bin/yunohost”, line 213, in
timeout=opts.timeout,
File “/usr/lib/python2.7/dist-packages/moulinette/init.py”, line 136, in cli
moulinette.run(args, output_as=output_as, password=password, timeout=timeout)
File “/usr/lib/python2.7/dist-packages/moulinette/interfaces/cli.py”, line 390, in run
ret = self.actionsmap.process(args, timeout=timeout)
File “/usr/lib/python2.7/dist-packages/moulinette/actionsmap.py”, line 498, in process
return func(**arguments)
File “/usr/lib/moulinette/yunohost/backup.py”, line 2122, in backup_restore
restore_manager.mount()
File “/usr/lib/moulinette/yunohost/backup.py”, line 1025, in mount
self.method.mount(self)
File “/usr/lib/moulinette/yunohost/backup.py”, line 1868, in mount
tar.extractall(members=subdir_and_files, path=self.work_dir)
File “/usr/lib/python2.7/tarfile.py”, line 2081, in extractall
self.extract(tarinfo, path)
File “/usr/lib/python2.7/tarfile.py”, line 2118, in extract
self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
File “/usr/lib/python2.7/tarfile.py”, line 2211, in _extract_member
self.utime(tarinfo, targetpath)
File “/usr/lib/python2.7/tarfile.py”, line 2332, in utime
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
OverflowError: Python int too large to convert to C long

Le script a créé le répertoire /home/yunohost.backup/tmp, qui contient 208Go de données.
Mais, mon serveur est loin d’être fonctionnel

Que puis-je faire pour migrer mon serveur de la machine actuelle vers ma VM en utilisant la technique du “yunohost backup/yunohost restore” ?

Les applications installées:

  • Nextcloud
  • Rainloop
  • OpenSondage
  • Shell in a box
  • PhpMyAdmin

Aucune configuration spécifique ou exotique effectuée.

My YunoHost configuration

Internet access: Fiber 1GB
YunoHost version:
yunohost: latest version
yunohost-admin: latest version
moulinette: latest version
ssowat: latest version

Le résultat d’un ‘df -h’:
/dev/mapper/VM–LCDR–NEW–vg-root 5,7G 2,2G 3,2G 40% /
/dev/sda1 236M 63M 162M 28% /boot
/dev/mapper/DATAS-HOME 536G 453G 57G 89% /home

et un ‘ls -thl’ dans le répertoire /home/yunohost.backup/archives,
root@VM-LCDR-NEW:/home/yunohost.backup/archives# ls -htl
total 246G
-rw-r–r-- 1 root root 246G juil. 21 19:29 test-20180721.tar.gz
-rw-r–r-- 1 root root 2,2K juil. 21 11:16 test-20180721.info.json

{
“host”: “Debian 9.5”,
“kernel”: “4.9.0-7-amd64”,
“packages”: {
“yunohost”: {
“repo”: “stable”,
“version”: “3.0.0.1”
},
“yunohost-admin”: {
“repo”: “stable”,
“version”: “3.0.0”
},
“moulinette”: {
“repo”: “stable”,
“version”: “3.0.0”
},
“ssowat”: {
“repo”: “stable”,
“version”: “3.0.0”
}
},
“backports”: ,
“system”: {},
“nginx”: [
“nginx: the configuration file /etc/nginx/nginx.conf syntax is ok”,
“nginx: configuration file /etc/nginx/nginx.conf test is successful”
],
“services”: {
“glances”: “exited (enabled)”,
“nslcd”: “running (enabled)”,
“metronome”: “running (enabled)”,
“postfix”: “exited (enabled)”,
“rspamd”: “running (enabled)”,
“yunohost-firewall”: “exited (enabled)”,
“dovecot”: “running (enabled)”,
“nginx”: “running (enabled)”,
“php7.0-fpm”: “running (enabled)”,
“dnsmasq”: “running (enabled)”,
“fail2ban”: “running (enabled)”,
“yunohost-api”: “running (enabled)”,
“mysql”: “running (enabled)”,
“avahi-daemon”: “running (enabled)”,
“shellinabox”: “running (enabled)”,
“redis-server”: “running (enabled)”,
“slapd”: “running (enabled)”,
“ssh”: “running (enabled)”
},
“applications”: {
“phpmyadmin”: “phpMyAdmin”,
“opensondage”: “OpenSondage”,
“rainloop”: “Rainloop”,
“shellinabox”: “Shell In A Box”,
“nextcloud”: “Nextcloud”
},
“security”: {
“CVE-2017-5754”: {
“name”: “meltdown”,
“vulnerable”: false
}
}

Bonjour,

Peut-être séparé l’application Nextcloud du reste pour effectuer une sauvegarde yunohost sans nextcloud et ensuite copier les datas comme inspiré dans le sujet suivant :

Bon install

martoni

1 Like

Effectivement, j’ai fait quelques tests, et en supprimant Nextcloud, ça semble fonctionner parfaitement !!

merci @martoni35

Rebonjour @martoni35

Il faut vraiment que je finalise ma virtualisation de mon instance yunohost, ne serait-ce que pour minimiser le nombre de machines qui tournent à un instant T.

Par contre, ma vraie question, c’est:

  • Est-ce qu’un ‘yunohost backup create MonBackup --system’ sur l’ancienne machine, suivi d’un ‘yunohost backup restore MonBackup’ sur la nouvelle, fera la synchronisation des agendas et carnets d’adresse Netxcloud ?

Si ça n’est pas le cas, quel est le moyen le plus simple de faire un backup/restore des éléments autres que fichiers dans NextCloud ??

Ci-dessous, le bout de script que j’utilise pour franchir le pas:

BKPMNTPOINT=“/home/yunohost.backup.nfs”
BKPPREFIX=“bkpmove-”
OCC=“sudo -u nextcloud /usr/bin/php /var/www/nextcloud/occ”
fusermount -u ${BKPMNTPOINT} 2>/dev/null
sshfs root@192.168.111.8:/home/yunohost.backup ${BKPMNTPOINT}

rsync -avz --partial --progress --delete-before /var/mail/ root@192.168.111.8:/var/mail/
${OCC} trashbin:expire
${OCC} trashbin:cleanup
${OCC} maintenance:mode --on
rsync -avz --partial --progress --delete-before /home/yunohost.app/nextcloud root@192.168.111.8:/home/yunohost.mov/
${OCC} maintenance:mode --off
mkdir ${BKPMNTPOINT}/archives 2>/dev/null
for i in $(yunohost backup list |tail -n +2|cut -d " " -f 4|grep ${BKPPREFIX})
do
echo Suppression du backup $i
yunohost backup delete $i
done
yunohost backup create -n ${BKPPREFIX}$(date ‘+%Y%m%d_%H’) -o ${BKPMNTPOINT}/archives --system
fusermount -u ${BKPMNTPOINT} 2>/dev/null && echo “Démontage OK de ${BKPMNTPOINT}”

Donc, sur la nouvelle machine, je dois faire:

  • yunohost backup restore DernierBackup
  • Réinstaller les différentes applications.
  • Faire les redirections de ports nécessaires.
  • Déplacer les fichier NextCloud dans le bon répertoire.
  • faire un ‘sudo -u nextcloud /usr/bin/php /var/www/nextcloud/occ files:scan --all’

Par contre, je ne sais pas si les:

  • Carnets d’adresse
  • Listes de tâches
  • Calendriers
    seront restorés…

Qui peut m’aider à finaliser tout ça ?

yunohost backup restore DernierBackup

Bonjour,

Pour commencer ta citation ci-dessous permet la sauvegarde de la solution globale de yunohost, ses paramètres et ses applications avec configuration.
Cependant, en partant du principe que l’on retire les datas de nextcloud pour les intégrer suite à la restauration de yunohost, la réponse est Non pour la citation suivante :

En effet, lorsque tu auras restauré yunohost, il faudra remettre tes datas Nextcloud avant de tester cette même application.Comme cela, à l’ouverture de nextcloud, tu retrouveras tes datas fichiers mais aussi tes applications nextcloud comme agenda et contact.
Normalement, ils seront désactivés mais à l’activation, nextcloud agenda et contacts retrouveront les datas car la bdd sera restaurée et tes datas présentes.
En revanche, j’ai déjà eu des restaurations nextcloud avec un agenda vide ou contact absent !!!
Donc, tu pourrais ajouter une backup agenda (fichier monagenda.ics) et contacts (fichier mescontacts.vcf) !!

Enfin, voici mes réponses pour ceci :

  • yunohost backup restore DernierBackup => oui
  • copier les datas nextcloud et mettre les bons droits => à ajouter dès la fin de yunohost restore mabackup
  • Réinstaller les différentes applications => oui
  • Faire les redirections de ports nécessaires => oui et testé https://ports.yunohost.org
  • Déplacer les fichier NextCloud dans le bon répertoire => non, étape à placer en second
  • faire un ‘sudo -u nextcloud /usr/bin/php /var/www/nextcloud/occ files:scan --all’ => pas forcement utile
    Ex : avec mes 130Go de data, je ne scan pas et à l’ouverture de nextcloud, tout est là.

En espérant que cela soit clair, bonne installation !!

martoni

EN
It’s possible to make a backup of Nextcloud without files and to restore it, next you need to copy files and rescan its.

BACKUP_CORE_ONLY=1 yunohost backup create --apps nextcloud --ignore-system

Note: --ignore-system need to be remove on Yunohost 3 and more


FR
Il est possible de faire un backup de Nextcloud sans les fichiers et de le restaurer il ne reste alors qu’à copier les fichiers et rescanner.

BACKUP_CORE_ONLY=1 yunohost backup create --apps nextcloud --ignore-system

NB: --ignore-system est à enlever si on est sur YunoHost 3 ou +

Thank you very much @martoni35 et @ljf
I’m going to try that quickly.

Hi @ljf @martoni35

In fact, I’m not able to complete the backup.
image

In my Humble Opinion, I think the avaible disk space is sufficient:
image

Is there a way to disable the drive space verification ?

Finally, the good syntax, in order to backup Netxtcloud Core Only is:

yunohost app setting nextcloud backup_core_only -v 1

And then, it is possible to start a full backup without NextCloud data…

1 Like

Finally, I was able to migrate. But it has not been a piece of cake…

I made a complete backup without nextcloud datas. (I tried several things !).

yunohost app setting nextcloud backup_core_only -v 1
yunohost backup create -n ${BKPFULLPREFIX}${BKPSUFFIX} -o ${BKPMNTPOINT}/archives
yunohost app setting nextcloud backup_core_only -v 0

I also made a backup of nextcloud database.

${OCC} maintenance:mode --on
rsync -Aavz --partial --progress --delete-before /home/yunohost.app/nextcloud root@${REMOTEADDRESS}:/home/yunohost.mov/
mysqldump --single-transaction nextcloud >/tmp/NextCloud-DB${BKPSUFFIX}.bak
${OCC} maintenance:mode --off

On the new server, I restored the full backup, while the nextcloud installation failed.
So I reinstalled nextcloud manually. I restored the datas in their normal location, and then I deleted the nextcloud mariadb database, and restored the nextcloud mariadb database.

I had to make a:

chown -R nextcloud:nextcloud /home/yunohost.app/nextcloud/data

After a reboot, everything was running fine…

thank you again for your help @martoni35, @ljf