H
H
HighMan2022-02-22 15:21:10
linux
HighMan, 2022-02-22 15:21:10

How to make a full system backup (Linux) rsync or tar?

Good time colleagues!
It is necessary to automate the backup of virtual machines (Linux) running qemu/kvm.
You need to completely back up "/".
The process of mounting the qcow machine and other preparatory steps have already been done and there are no difficulties.
/ (stopped) virtual machine is mounted in / mnt
Tried via rsync
rsync -av /mnt /srv/vm_name
Recovered the same way
rsync -av /srv/vm_name /mnt
The system crashes on the initramfs. Probably something with file permissions.
I tried with tar

cd /mnt
tar -cvzpf /srv/vm_name.tar.gz .

Recovery:
cd /mnt
tar --same-owner -xvpf /srv/vm_name.tar.gz

Already better!
VM is loading...
But! Does not allow login with password. Neither via console nor via ssh.
When entering through the console, he tries to say something, but so quickly that I do not have time to read it.
When I try to log in via ssh, immediately after entering the login and password, the connection breaks.
Distribution on VM Fedora35.
It seems, Debian, after the restoration it works fine. Didn't check.
I want to clarify right away: do not offer dd, veem, acronis & etc!
cp vm_name.qcow2 vm_name.qcow.bak Also not interesting.
The most interesting option is with rsync. At worst, tar.
Well, optional: is it possible to back up Windows (7,8,10 ....) in a similar way?

UPD /boot in a separate disk partition

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
meDveD_spb, 2022-02-22
@meDveD_spb

where did the idea come from that these might be suitable options?
this is not true.

running qemu/kvm.

install PVE, then PBS. all.

M
MaxKozlov, 2022-02-23
@MaxKozlov

I don’t know why, but you can look at rear
https://relax-and-recover.org/
there are both tar and rsync and whatever you
want

O
Oleg Volkov, 2022-02-22
@voleg4u

There are also snapshots, on the level of QEMU or libvirt. You can read HERE

R
rPman, 2022-02-22
@rPman

So, first and foremost - the method, format and time of creating a backup should be determined by the methods by which this backup will be restored.
(if virtual machines are used, look, perhaps the tools built into the hypervisor already contain the answer. For example, if snapshots are not used, then a database backup is a copy of its disk container files)
Second, there are a huge number of ways to create an operating system backup, each of them is distinguished by the convenience of both creating a copy and restoring it, and the pros are not always combined with the cons.
File-level backup is rsync or tar, allows you to control what to copy and what to skip at the file level, but the slowest possible. Remember, if files are being written to, then normally a backup copy can only be made from a snapshot or by turning off the machine. To restore, this method requires the most gestures, but as one of the steps, a
backup at the block device level is quite acceptable:
* as I already said, if the virtual machine uses files to store disk images, you can simply copy them (by disabling or suspending it by itself , or using hypervisor snapshots)
* you can copy disks from the inside from the guest system using its tools, in this case you can use its snapshot technology
For example, in linux, when using btrfs, you can instantly create a snapshot and get the difference between this snapshot and the previous one in the form of a file (stream), store them and then apply these incremental copies sequentially to another starting copy of the disk (this can be done starting from an empty disk)
An important point , to obtain guarantees, it is better to either stop the databases while creating a copy or do a backup using its means, otherwise the probability of problems during their restoration will not be zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question