S
S
svoyak2016-03-03 22:06:58
Backup
svoyak, 2016-03-03 22:06:58

Full system backup on LVM?

There is ubuntu, which, during installation, offered to create itself on LVM, now I'm racking my brains on how to back up this scheme.

NAME                         FSTYPE      LABEL MOUNTPOINT
sda                                            
├─sda1                       vfat              
├─sda2                       ext2              /boot
└─sda3                       LVM2_member       
  ├─ubuntu--vg-root (dm-0)   ext4              /
  └─ubuntu--vg-swap_1 (dm-1) swap              [SWAP]

I read a bunch of articles on LVM, incl. about creating and restoring snapshots. But apparently this is not what I need.
Requires a full system backup from a 500GB SSD to an external 120GB SSD (used space on the first < 120GB). Those. if the screw suddenly dies, a similar or larger size is bought and the entire system is restored from the backup with a slight movement of the console line. I used to do this with dd if=/dev/sda archiving on the fly. How to do it now?
There are only two options as far as I can tell.
1. in the same way using the dd
utility 2. make a snapshot of /dev/ubuntu-vg/root and if the hard dies, install ubuntu again on LVM, then roll the snapshot.
In the second case, I did not figure out how to export the snapshot directly to an external drive as a file, without creating it on the working hard.
What other options are there?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lovecraft, 2016-03-05
@lovecraft

As I understand it, you need a disaster recovery, i.e. data recovery to an empty disk. This is done in the following way. Suppose you have /media/ssd01 directory on the server with backup-storage backups, then
1. Mount the directory
mount -t nfs backup-storage:/media/ssd01 /mnt/backup
2. Create a subdirectory with backup
export backupdate=$( date --iso-8601=seconds)
mkdir /mnt/backup/backup-$(backupdate)
3. You seem to have a GPT partition, so use sgdisk. Back up the disk layout to a file.
sudo sgdisk -b /mnt/backup/backup-$(backupdate)/disk_layout.bin /dev
/
sda backup-$(backupdate)/EFI
mkdir /mnt/backup/backup-$(backupdate)/boot
cp -a /<where is sda1 mounted there and is it mounted at all?> /mnt/backup/backup-$(backupdate)/EFI
cp -a /boot /mnt/ backup/backup-$(backupdate)/boot
5. Copy the location of the LVM partitions
vgcfgbackup -f /boot /mnt/backup/backup-$(backupdate)/lvm.txt
6. Snapshot the root partition
lvcreate -s -n backup - L20G /dev/ubuntu--vg/root
7. Back up only completed snapshot blocks partclone.extfs
-c -s /dev/ubuntu--vg/backup -o /mnt/backup/backup-$(backupdate)/ubuntu-- vg-root.img
8. Remove the snapshot
lvremove /dev/ubuntu--vg/backup
9. Unmount the backup directory
umount /mnt/backup
The whole thing is driven into the script and twitches once a day on the crown. Expand - in the same order, but there are subtleties, for example, before vgcfgrestore you need to do pvcreate --restorefile <file> --uuid .
Copying /dev/sda via dd is a very bad idea, you will lose filesystem integrity. The write resource of the SSD is now such that you can not be afraid to write to it as much as you need.

V
Vasily Pechersky, 2016-03-03
@Vasily_Pechersky

You need to take off your windowed glasses and enjoy life ......
Linux is built on files. You can just copy them.
There is, for example, the rsync utility, which redraws only changed files.
Since you did not specify the purpose of using this machine, I will simply mention that database servers cannot be backed up in this way and their toolkit must be used.

S
stigory, 2016-03-04
@stigory

Treat LVM2 as an extra layer of abstraction. You are free to ignore it when it suits you and remember it when necessary.
Your usual toolkit will continue to work as before. So there are two options listed. The difference is only in the approach.
In the first case, in order not to risk data consistency when working with dd , it is recommended to suspend the services and the system. This is often inconvenient.
In the second case, you start to take advantage of LVM. A snapshot is the freezing of data on a disk. All subsequent changes are written on a new layer. In this case, you can safely back up the snapshot without interrupting the system and services. And at the end, merge the changes with the snapshot, then deleting it.
No way. You have not understood the essence of snapshot. It is your data on the disk.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question