Outils pour utilisateurs

Outils du site


borg

Ceci est une ancienne révision du document !


Borg

Initialiser un repo de backup

# borg init -e keyfile /mnt/data/backups/raspberrypi
Enter new passphrase: 
Enter same passphrase again: 
Do you want your passphrase to be displayed for verification? [yN]: y
Your passphrase (between double-quotes): "maSuperLongueEtCompliquéePassphrase"
Make sure the passphrase displayed above is exactly what you wanted.
 
By default repositories initialized with this version will produce security
errors if written to with an older version (up to and including Borg 1.0.8).
 
If you want to use these older versions, you can disable the check by runnning:
borg upgrade --disable-tam '/mnt/data/backups/raspberrypi'
 
See https://borgbackup.readthedocs.io/en/stable/changes.html#pre-1-0-9-manifest-spoofing-vulnerability for details about the security implications.
# ls -al /mnt/data/backups/
total 68
drwxr-xr-x 3 root root  4096 jun 29 15:45 .
drwxr-xr-x 3 root root  4096 jun 29 15:43 ..
-rw------- 1 root root   164 jun 29 15:44 config
drwx------ 3 root root  4096 jun 29 15:45 data
-rw------- 1 root root    31 jun 29 15:45 hints.0
-rw------- 1 root root 41258 jun 29 15:45 index.0
-rw------- 1 root root    26 jun 29 15:44 README

Faire un premier backup

# borg create -v -s -p -C lzma,6 --exclude-from=/mnt/data/backups/raspberrypi-exclude /mnt/data/backups/raspberrypi::{hostname}-{now:%Y%m%d-%H%M%S} /
Enter passphrase for key /root/.config/borg/keys/mnt_data_backups_raspberrypi: 
2.53 GB O 1.41 GB C 1.37 GB D 64649 N var/lib/docker/overlay2/dd058fc33661deeca3f305d03...itemap-1.2.0/spec/fixtures/_posts/2016-04-02-错误.ht------------------------------------------------------------------------------                                                                
Archive name: raspberrypi-20190629-155955
Archive fingerprint: 7526334a84d9a8db637909dac461073e10a8f9fa4300f6b205459c1ee802ceee
Time (start): Sat, 2019-06-29 16:00:24
Time (end):   Sat, 2019-06-29 19:25:53
Duration: 3 hours 25 minutes 28.50 seconds
Number of files: 102169
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
This archive:                3.00 GB              1.55 GB              1.50 GB
All archives:                3.00 GB              1.55 GB              1.50 GB
 
                       Unique chunks         Total chunks
Chunk index:                   85977               100707
------------------------------------------------------------------------------

Le fichier raspberrypi-exclude contient les répertoire que je ne veux pas sauvegarder :

# cat /mnt/data/backups/raspberrypi-exclude
/mnt
/dev
/media
/proc
/run
/sys
/tmp
~/.cache/
/var/cache/

Un “borg list” nous montre bien ce premier backup :

# borg list /mnt/data/backups/raspberrypi/
Enter passphrase for key /root/.config/borg/keys/mnt_data_backups_raspberrypi: 
raspberrypi-20190629-155955          Sat, 2019-06-29 16:00:24

Alias et second backup :

# cat ~/.bash_aliases 
alias backup='borg create -v -s -p -C lzma,6 --exclude-from=/mnt/data/backups/raspberrypi-exclude /mnt/data/backups/raspberrypi::{hostname}-{now:%Y%m%d-%H%M%S} /'
 
# backup 
Enter passphrase for key /root/.config/borg/keys/mnt_data_backups_raspberrypi: 
------------------------------------------------------------------------------
Archive name: raspberrypi-20190630-100756
Archive fingerprint: 8f2aae9f8f3db9e086c746f686ddc999c8996e470cd066524509b6eb47253e7a
Time (start): Sun, 2019-06-30 10:08:10
Time (end):   Sun, 2019-06-30 10:11:54
Duration: 3 minutes 44.00 seconds
Number of files: 100691
------------------------------------------------------------------------------
                       Original size      Compressed size    Deduplicated size
This archive:                2.21 GB            806.89 MB              2.19 MB
All archives:                5.21 GB              2.36 GB              1.51 GB
 
                       Unique chunks         Total chunks
Chunk index:                   86057               199693
------------------------------------------------------------------------------

3 min 44 !

# borg list /mnt/data/backups/raspberrypi
Enter passphrase for key /root/.config/borg/keys/mnt_data_backups_raspberrypi: 
raspberrypi-20190629-155955          Sat, 2019-06-29 16:00:24
raspberrypi-20190630-100756          Sun, 2019-06-30 10:08:10

Info

# borg info /mnt/data/backups/raspberrypi::raspberrypi-20190630-100756
Enter passphrase for key /root/.config/borg/keys/mnt_data_backups_raspberrypi: 
Name: raspberrypi-20190630-100756
Fingerprint: 8f2aae9f8f3db9e086c746f686ddc999c8996e470cd066524509b6eb47253e7a
Hostname: raspberrypi
Username: root
Time (start): Sun, 2019-06-30 10:08:10
Time (end):   Sun, 2019-06-30 10:11:54
Command line: /usr/bin/borg create -v -s -p -C lzma,6 --exclude-from=/mnt/data/backups/raspberrypi-exclude /mnt/data/backups/raspberrypi::{hostname}-{now:%Y%m%d-%H%M%S} /
Number of files: 100691
 
                       Original size      Compressed size    Deduplicated size
This archive:                2.21 GB            806.89 MB              2.19 MB
All archives:                5.21 GB              2.36 GB              1.51 GB
 
                       Unique chunks         Total chunks
Chunk index:                   86057               199693

List et mount

On a déjà vu la commande bord list qui permet de voir les différentes sauvegardes effectuées. On peut aussi l'utiliser pour afficher tous les fichiers sauvegardés. (Attention, ça va afficher des centaines/milliers de lignes… C'est intéressant seulement pour vérifier qu'un fichier particulier est bien sauvegardé, j'imagine.)

# borg list /mnt/data/backups/raspberrypi::raspberrypi-20190630-100756

Sources

borg.1561883326.txt.gz · Dernière modification : 2020/08/09 12:59 (modification externe)