Sauvegarde LVM · 3 min read · Nov 05, 2025

Sauvegarder (et restaurer) des partitions LVM avec des instantanés LVM - Page 2

3 Créer un instantané LVM de /

Maintenant, il est temps de créer l’instantané du volume /dev/server1/root. Nous allons appeler l’instantané rootsnapshot:

lvcreate -L10G -s -n rootsnapshot /dev/server1/root

La sortie de

lvdisplay

devrait ressembler à ceci:

server1:~# lvdisplay
— Logical volume —
LV Name /dev/server1/root
VG Name server1
LV UUID UK1rjH-LS3l-f7aO-240S-EwGw-0Uws-5ldhlW
LV Write Access read/write
LV snapshot status source of
/dev/server1/rootsnapshot [active]
LV Status available

LV Size 9.30 GB
Current LE 2382
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0

— Logical volume —
LV Name /dev/server1/swap_1
VG Name server1
LV UUID 2PASi6-fQV4-I8sJ-J0yq-Y9lH-SJ32-F9jHaj
LV Write Access read/write
LV Status available

LV Size 464.00 MB
Current LE 116
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:1

— Logical volume —
LV Name /dev/server1/backups
VG Name server1
LV UUID sXq2Xe-y2CE-Ycko-rCoE-M5kl-E1vH-KQRoP6
LV Write Access read/write
LV Status available

LV Size 30.00 GB
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:2

— Logical volume —
LV Name /dev/server1/rootsnapshot
VG Name server1
LV UUID 9zR5X5-OhM5-xUI0-OolP-vLjG-pexO-nk36oz
LV Write Access read/write
LV snapshot status active destination for /dev/server1/root
LV Status available

LV Size 9.30 GB
Current LE 2382
COW-table size 10.00 GB
COW-table LE 2560
Allocated to snapshot 0.01%
Snapshot chunk size 8.00 KB
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:5

Nous voulons monter /dev/server1/rootsnapshot sur /mnt/server1/rootsnapshot, donc nous devons d’abord créer ce répertoire:

mkdir -p /mnt/server1/rootsnapshot

Ensuite, nous montons notre instantané:

mount /dev/server1/rootsnapshot /mnt/server1/rootsnapshot

Puis nous exécutons

ls -l /mnt/server1/rootsnapshot/

Cela devrait montrer tous les répertoires et fichiers que nous connaissons de notre partition /:

server1:~# ls -l /mnt/server1/rootsnapshot/
total 132
drwxr-xr-x 2 root root 4096 2007-04-10 21:02 backups
drwxr-xr-x 2 root root 4096 2007-04-10 20:35 bin
drwxr-xr-x 2 root root 4096 2007-04-10 20:25 boot
lrwxrwxrwx 1 root root 11 2007-04-10 20:25 cdrom -> media/cdrom
drwxr-xr-x 13 root root 40960 2007-04-10 20:36 dev
drwxr-xr-x 57 root root 4096 2007-04-10 21:09 etc
drwxr-xr-x 3 root root 4096 2007-04-10 20:36 home
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 initrd
lrwxrwxrwx 1 root root 28 2007-04-10 20:29 initrd.img -> boot/initrd.img-2.6.18-4-486
drwxr-xr-x 13 root root 4096 2007-04-10 20:34 lib
drwx—— 2 root root 16384 2007-04-10 20:25 lost+found
drwxr-xr-x 4 root root 4096 2007-04-10 20:25 media
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 mnt
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 opt
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 proc
drwxr-xr-x 3 root root 4096 2007-04-10 20:42 root
drwxr-xr-x 2 root root 4096 2007-04-10 20:36 sbin
drwxr-xr-x 2 root root 4096 2007-03-07 23:56 selinux
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 srv
drwxr-xr-x 2 root root 4096 2007-01-30 23:27 sys
drwxrwxrwt 2 root root 4096 2007-04-10 21:09 tmp
drwxr-xr-x 10 root root 4096 2007-04-10 20:26 usr
drwxr-xr-x 13 root root 4096 2007-04-10 20:26 var
lrwxrwxrwx 1 root root 25 2007-04-10 20:29 vmlinuz -> boot/vmlinuz-2.6.18-4-486

Donc notre instantané a été créé avec succès!

Maintenant, nous pouvons créer une sauvegarde de l’instantané sur la partition /backups en utilisant notre solution de sauvegarde préférée. Par exemple, si vous aimez faire une sauvegarde basée sur des fichiers, vous pouvez le faire comme ceci:

tar -pczf /backups/root.tar.gz /mnt/server1/rootsnapshot

Et si vous aimez faire une sauvegarde au niveau des bits (c’est-à-dire une image), vous pouvez le faire comme ceci:

dd if=/dev/server1/rootsnapshot of=/backups/root.dd

server1:~# dd if=/dev/server1/rootsnapshot of=/backups/root.dd
19513344+0 records in
19513344+0 records out
9990832128 bytes (10 GB) copied, 320.059 seconds, 31.2 MB/s

Vous pourriez également utiliser les deux méthodes pour être préparé à tout ce qui pourrait arriver à votre volume /dev/server1/root. Dans ce cas, vous devriez avoir deux sauvegardes par la suite:

ls -l /backups/

server1:~# ls -l /backups/
total 9947076
drwx—— 2 root root 16384 2007-04-10 21:04 lost+found
-rw-r–r– 1 root root 9990832128 2007-04-10 21:28 root.dd
-rw-r–r– 1 root root 184994590 2007-04-10 21:18 root.tar.gz

Ensuite, nous démontons et supprimons l’instantané pour éviter qu’il ne consomme des ressources système:

umount /mnt/server1/rootsnapshot
lvremove /dev/server1/rootsnapshot

C’est tout, vous venez de réaliser votre première sauvegarde à partir d’un instantané LVM.

Share: X/Twitter LinkedIn

Recevez de nouveaux articles dans votre boîte de réception.

Aucun spam. Désabonnez-vous à tout moment.