1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/borg_ynh.git synced 2024-09-03 18:16:05 +02:00

Merge pull request #41 from YunoHost-Apps/testing

Testing
This commit is contained in:
ljf (zamentur) 2020-06-17 23:52:02 +02:00 committed by GitHub
commit 51a4beaca6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 101 additions and 70 deletions

104
README.md
View file

@ -1,4 +1,4 @@
# Borg for Yunohost
# Borg Backup App for YunoHost
[![Latest Version](https://img.shields.io/badge/version-1.0.3-green.svg?style=flat)](https://github.com/YunoHost-Apps/borg_ynh/releases)
[![Status](https://img.shields.io/badge/status-testing-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/borg_ynh/milestones)
@ -8,19 +8,23 @@
[![Install Borg with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=borg)
An experimental borg implementation for yunohost
A [Borg](https://borgbackup.readthedocs.io/en/stable/index.html#what-is-borgbackup) implementation to backup a YunoHost server. This is the Borg Backup App to be installed on a server to backup. It works together with a [Borg Server App](https://github.com/YunoHost-Apps/borgserver_ynh) installed on a host server.
## Usage
If you want to backup your server A onto the server B.
## Setup borg app on Server A
Firstly set up this app on the server A you want to backup:
# How does it work? Set up Borg Apps
You want to backup a critical "guest" Server A onto a remote "host" Server B, you need:
* Domain name of server B: ``host.serverb``
* Name of the server B SSH user (to be created by ``borgserver``) for connection from Server A: ``borgservera``
* **Strong passphrase** to encrypt your backups on host Server B. And to **restore your backups**!!
* IDs of YunoHost apps you want to backup
* Regular time schedule for your backups, see below
* Install Borg Backup App (``borg``) on guest Server A
* Install Borg Server App (``borgserver``) on host Server B
## Set up Borg Backup App on guest Server A
Firstly, set up the Borg Backup App (``borg``) on the guest Server A you want to backup:
```
$ yunohost app install https://github.com/YunoHost-Apps/borg_ynh
Indicate the server where you want put your backups: serverB.local
$ yunohost app install borg_ynh
Indicate the domain name of server B where to upload backups: host.serverb
Indicate the ssh user to use to connect on this server: servera
Indicate a strong passphrase, that you will keep preciously if you want to be able to use your backups: N0tAW3akp4ssw0rdYoloMacN!guets
Would you like to backup your YunoHost configuration ? [0 | 1] (default: 1):
@ -29,65 +33,73 @@ Which apps would you backup (list separated by comma or 'all') ? (default: all):
Indicate the backup frequency (see systemd OnCalendar format) (default: Daily):
```
You can schedule your backup by choosing an other frequency. Some example:
Monthly :
Weekly :
Daily : Daily at midnight
Hourly : Hourly o Clock
Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00
4:00 : Every day at 4 AM
5,17:00 : Every day at 5 AM and at 5 PM
### Syntax to define a backup time schedule
You can schedule regular backups at specific time. Only one regular time schedule is possible for one ``borg`` instance, see below for workaround. Some examples:
* Monthly :
* Weekly :
* Daily : Daily at midnight
* Hourly : Hourly o Clock
* Sat *-*-1..7 18:00:00 : The first saturday of every month at 18:00
* 4:00 : Every day at 4 AM
* 5,17:00 : Every day at 5 AM and at 5 PM
See here for more info : https://wiki.archlinux.org/index.php/Systemd/Timers#Realtime_timer
At the end of the installation, the app display you the public_key and the user to give to the person who has access to the server B.
### Information generated by Borg Backup
At the end of the installation, the Borg Backup App (``borg``) displays the SSH public key and the SSH user to give to the person who has access to the host Server B and will set up Borg Server App.
```
You should now install the "Borg Server" app on serverb.local and fill questions like this:
You should now install the "Borg Server" app on host.serverb and fill questions like this:
User: servera
Public key: ssh-ed25519 AAAA[...] root@servera.local
Public key: ssh-ed25519 AAAA[...] root@guest.servera
```
If you don't find the mail and you don't see the message in the log bar you can found the public_key with this command:
This information is also sent by email to the admin of guest Server A.
If you don't find the mail and you don't see the message in the log bar you can find the SSH public key with this command:
```
$ cat /root/.ssh/id_borg_ed25519.pub
ssh-ed25519 AAAA[...] root@servera.local
ssh-ed25519 AAAA[...] root@guest.servera
```
## Setup Borg Server app on Server B
## Set up Borg Server App on host Server B
Secondly, set up the Borg Server App (``borgserver``) on the host Server B that will store your backups:
```
$ yunohost app install https://github.com/YunoHost-Apps/borgserver_ynh
$ yunohost app install borgserver
Indicate the ssh user to create: servera
Indicate the public key given by borg_ynh app: ssh-ed25519 AAAA[...] root@servera.local
Indicate the public key given by Borg Backup app (borg) setup: ssh-ed25519 AAAA[...] root@guest.servera
Indicate the storage quota: 5G
```
## Test
At this step your backup should schedule.
# Test the Borg Apps setup
At this step your backup should run at the scheduled time. Note that the first backup can take very long, as much data has to be copied through ssh. Following backups are incremental: only newly generated data since last backup will be copied.
If you want to be sure, you can test it by running on server A:
If you want to test correct Borg Apps setup before scheduled time, you can start a backup manually on guest Server A:
```
$ service borg start
```
Next you can check, your backup on server B
Next you can check presence of your backup repository on host Server B:
```
$ borg list /home/servera/backup
```
You will need the passphrase to run ``borg`` commands on the backup repository created on the host Server B.
YOU SHOULD CHECK REGULARLY THAT YOUR BACKUP ARE STILL WORKING.
YOU SHOULD REGULARLY RESTORE YOUR BACKUPS TO TEST THEIR VALIDITY.
## Edit the apps list to backup
# Usage and documentation
yunohost app setting borg apps -v "nextcloud,wordpress"
## Edit the list of YunoHost apps to backup
``yunohost app setting borg apps -v "nextcloud,wordpress"``
## Backup on different server, and apply distinct schedule for apps
## Other usefull borg commands
[Get the storage space used by the backup repository on the host server](https://borgbackup.readthedocs.io/en/stable/usage/info.html)
``borg info /home/servera/backup``
You can setup the borg apps several times on the same server so you can backup on several server or manage your frequency backup differently for specific part of your server.
## Backup Yunohost apps with different criticallity levels
If you want to backup your guest server:
* with different YunoHost apps
* at different regular time schedule
* on different host servers
Then you can set up multiple instances of the Borg Apps on same servers.
For instance:
* Borg Backup instance ``borg``: backup nextcloud daily on host Server B
* Borg Backup instance ``borg__2``: backup all other YunoHost apps weekly on host Server C

View file

@ -29,8 +29,19 @@ fi
# Backup all apps independently
apps=$(yunohost app setting {{ app }} apps)
for app in $(yunohost app list --installed -b | grep id: | cut -d: -f2); do
if [[ "$apps" = *"$app,"* ]] || [ "$apps" = "all" ]; then
for app in $(ls /etc/yunohost/apps/*/scripts/backup | cut -d / -f 5); do
backup_app=false
if [[ "$apps" = "all" ]]; then
backup_app=true
else
for selected_app in $(echo $apps | tr "," " ");do
if [[ "$selected_app" == "$app" ]]; then
backup_app=true
break
fi
done
fi
if [ "$backup_app" == "true" ];then
yunohost backup create $ignore_system -n auto_$app --method {{ app }}_app --apps $app
fi
done

View file

@ -1,10 +1,10 @@
{
"name": "Borg",
"name": "Borg Backup App",
"id": "borg",
"packaging_format": 1,
"description": {
"en": "Backup your server with borg.",
"fr": "Sauvegarder votre serveur avec borg."
"en": "Backup your server on a host server using Borg.",
"fr": "Sauvegardez votre serveur sur un serveur distant avec Borg."
},
"version": "1.1.10~ynh1",
"url": "https://borgbackup.readthedocs.io",
@ -24,37 +24,45 @@
{
"name": "server",
"ask": {
"en": "Indicate the server where you want put your backups",
"fr": "Indiquez le serveur où vous voulez faire vos sauvegardes"
"en": "What is the domain name of the host server where backups will be sent?",
"fr": "Quel est le nom de domaine du serveur distant sur lequel seront envoyés les sauvegardes ?"
},
"help":{
"en": "If the ssh remote server doesn't use a standard port, you could specify it with DOMAIN:PORT",
"fr": "Si le serveur ssh n'utilise pas un port standard, vous pouvez le spécifier avec DOMAIN:PORT"
"en": "If this host server does use a custom SSH port (different from 22), you can specify it with DOMAIN:PORT",
"fr": "Si le serveur distant utilise un port particulier pour SSH (différent de 22), vous pouvez le spécifier avec DOMAIN:PORT"
},
"example": "example.com:22"
"example": "host.serverb:22"
},
{
"name": "ssh_user",
"ask": {
"en": "Indicate the ssh user to use to connect on this server",
"fr": "Indiquez l'utilisateur ssh à utiliser pour se connecter au serveur"
"en": "Which SSH username should be used to connect to the host server?",
"fr": "Quel utilisateur faut-il utiliser pour se connecter au serveur distant ?"
},
"example": "john"
"help":{
"en": "It is not meant to be an existing user on this guest server. Instead, it will be created *on the host server* during the installation of the Borg Server App.",
"fr": "Cet utilisateur n'est pas censé exister sur ce serveur. Il sera créé *sur le serveur distant* lors de l'installation de l'App Borg Server sur celui-ci."
},
"example": "borgservera"
},
{
"name": "passphrase",
"type": "password",
"ask": {
"en": "Indicate a strong passphrase, that you will keep preciously if you want to be able to use your backups",
"fr": "Indiquez une phrase de passe forte que vous garderez précieusement si vous voulez être en mesure d'utiliser vos sauvegardes"
"en": "Provide a strong passphrase to encrypt your backups. No blank space",
"fr": "Indiquez une phrase de passe forte pour chiffrer vos sauvegardes. Sans espaces"
},
"help":{
"en": "Keep it safe! ...if you want to be able to restore. Do not communicate it to host Server holder or anyone else. ",
"fr": "Gardez-la précieusement! ...si vous voulez pouvoir restaurer. Ne donnez pas la clé au possesseur du Serveur distant, ni personne."
}
},
{
"name": "conf",
"type": "boolean",
"ask": {
"en": "Would you like to backup your YunoHost configuration ?",
"fr": "Souhaitez-vous effectuer des sauvegardes des configurations du système YunoHost ?"
"en": "Should Borg backup your YunoHost configuration ?",
"fr": "Borg doit-il sauvegarder la configuration système YunoHost ?"
},
"default": true
},
@ -62,26 +70,26 @@
"name": "data",
"type": "boolean",
"ask": {
"en": "Would you like to backup mails and user home directory ?",
"fr": "Souhaitez-vous effectuer des sauvegardes des mails et des répertoire des utilisateurs ?"
"en": "Should Borg backup emails and user home directory ?",
"fr": "Borg doit-elle sauvegarder les mails et les répertoires des utilisateurs ?"
},
"default": true
},
{
"name": "apps",
"ask": {
"en": "Which apps would you backup (list separated by comma or 'all') ?",
"fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
"en": "Which apps should Borg backup (list separated by comma or 'all') ?",
"fr": "Quelles applications doivent être sauvegardées par Borg (liste séparée par virgule ou 'all' ?"
},
"default": "all"
},
{
"name": "on_calendar",
"ask": {
"en": "Indicate the backup frequency (see systemd OnCalendar format)",
"fr": "Indiquez la fréquence de la sauvegarde (voir le format OnCalendar de systemd)"
"en": "With which regular time schedule should the backups be performed ? (see systemd OnCalendar format)",
"fr": "À quelle fréquence les sauvegardes doivent-elles être effectuées ? (voir le format OnCalendar de systemd)"
},
"example": "Daily",
"example": "Monthly or Weekly or Daily or Hourly or 4:00 or 5,17:00 or Sat --1..7 18:00:00",
"default": "Daily"
}
]