How to properly backup and restore?

Hello there!

I am new to self hosting and I am trying to get used to yunohost environment. I feel almost comfortable with the base system and some of the apps that I plan to use, like nextcloud, rainloop etc. but, I couldn’t find a lot of information on backup with Borg.

I have 2 servers in 2 different locations and I’ve installed yunohost on both of them. One of the servers are linked with a domain and has enough hardware to run my apps for a couple of users at the same time. The other server has weaker hardware, and it will only be used for backup purposes. Both of the devices has 2TB of space available.

In case of a problem on main server, I would like to be able to restore a backup from backup server to new/fixed main server.

To achieve this, I installed BorgBackup and BorgServer to try it out and I set the apps on both sides. It performed a backup without an issue as well. But, I couldn’t find how to restore the backup to main server on the app, or in documentations.

Also I don’t know if there is a better way to backup and restore yunohost in my circumstances. I am looking for your responses…

From what I recall, there’s a borg command to convert a borg backup into a .tar.gz archive that can be fed to Yunohost’s backup system (to be able to restore it)

I’m sure @ljf has some more info on this :wink:

To check your backup

cd /home/BORG_USER/backup
borg list ./

You will be asked for the passphase you give during borg_ynh install.

You can check specifically an archive by:

borg list ./::ARCHIVE_NAME

You can check integrity by listing info.json file, and check if db are correctly backupped up:

borg list ./::ARCHIVE_NAME | grep info.json
borg list ./::ARCHIVE_NAME | grep db.sql
borg list ./::ARCHIVE_NAME | grep dump.sql

Restore an archive

To restore an archive with YunoHost <=4.0.7 (current version), you can recreate a tar.gz of the app or part you need to restore:

borg export-tar BORG_USER@DOMAIN_OF_BACKUP_SERVER:backup::auto_XXXX /home/yunohost.backup/archives/auto_XXXX.tar.gz

yunohost backup restore auto_XXXX

CAUTION: Borg and BorgServer split backup in several archives (one for the conf, one for the data, one per app…), so you need to restore in this order if you want to do a complete restoration.

You need enough bandwidth, and space to do this operation…

Tips: if you backup nextcloud data, but want only restore nextcloud without data (because you already have the data dir in the new server), you can exclude the dir:

borg export-tar -e apps/nextcloud/backup/home/yunohost.app BORG_USER@DOMAIN_OF_BACKUP_SERVER:backup::auto_XXXX /home/yunohost.backup/archives/auto_XXXX.tar.gz
1 Like

Thank you @ljf! I’ll give this a try as soon as I can.

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