How to do Qubes OS backups in command line

Hello,

How can I do backup without using the graphical interface but only using command line ? I can’t find anything on internet, is this even possible to do it ?

qvm-backup as stated in the docs.

3 Likes

aaaahh I already saw it, but I was typing qubes-backup instead of qvm-backup, my bad :see_no_evil:

1 Like

Yes. I also make this mistake sometimes. In general qubes-* commandline tools apply to the system and qvm-* are applied to a particular qube.

2 Likes

Because there is no example on the documentation, I’m putting some here if someone need it :

qvm-backup --no-compress --yes --dest-vm vault /path/of/my/folder

qvm-backup --verbose --no-compress --yes --dest-vm vault /path/of/my/folder

qvm-backup --compress --yes --dest-vm vault /path/of/my/folder

3 Likes

I was just perusing the documentation in order to see some command line usage examples for qvm-backup utility. Thanks for these examples but these three only seem to scratch the surface of the capabilities of Qubes Backup GUI.

For example, how do I tell the command line tool qvm-backup to exclude certain qubes from back ups? How do I tell it to include only dom0 home folder to the backups? How do I decide how’s my usage profile saved and stored?

It would be helpful to see such examples, too.

man qvm-backup is your friend:

--exclude, -x

--save-profile

I mean, I checked the man qvm-backup but it’s pretty barebones. For example, does the --exclude take comma separated variables if I want to exclude more than one qubes?

Never used it, you can try.

It does say:

may be repeated

so you could run qvm-backup -x VM1 -x VMn.

OK, so I read the man page. And I prepared a qubes-manager-backup.conf file as follows:

$ cat ~/.config/qubes-manager-backup.conf
compression: true
destination_path: /media/user/GOODLUCK
destination_vm: personal
include:
- dom0
passphrase_text: mymypassphrase

And then I run the qvm-backup as follows:

$ qvm-backup --profile ~/.config/qubes-manager-backup.conf

which returns

$ qvm-backup --profile ~/.config/qubes-manager-backup.conf
Backup preparation error: Got empty response from qubesd. See journalctl in dom0 for details.

I look at the journalctl, and the related line reads:

qubesd[1914]: permission denied for call b'admin.backup.Info'+b'/home/tanky0u/.config/qubes-manager-backup.conf' (b'dom0'  -> b'dom0') with payload of 0 bytes

Running the same qvm-backup command with sudo gives the same error. Any other tips?

man qvm-backup will help

Yes, someone else suggested reading the man page, too. In the following conversation under this thread, I wrote that I had read the man, and I was having another problem with using the qvm-backup in the command line. Please see that post of mine.

Haven’t used it but try to place the config file in /root (taking care of permissions) and run it again with sudo.

# mkdir -p /root/.config
# cat /home/user/.config/qubes-manager-backup.conf | tee /root/.config/qubes-manager-backup.conf 

If you run the above as root, perms will be taken care of.

From your suggestion, I thought that perhaps having the --profile file in my user’s home directory wasn’t allowing the admin user to reach that file, since my ~/.config is only reachable by my user.

So, I just moved the file to /etc/qubes/backup/ folder. The file’s user and group are my user’s, however, “other” has “read” permissions, too.

Mind you that this is where the default --profile file resides, also.

However, running the same command with the updated location of the --profile file still gives the same error.

Before I do your suggested solution, I wanted to point this strangeness out. Why is the command still failing even though it has the read permissions given?

I’m not sure, but you could still try to re-make (with cat and tee) that file instead of moving it.

Used your suggestion (cat and tee), and re-run the qvm-backup command with

$ sudo qvm-backup --profile /root/.config/qubes-manager-backup.conf

However, it gave the same “Backup preparation error:” as in the above posts.
The command without sudo also gives the same error.

This is getting awkward and frustrating. I just wanted to use the command line while doing backups.

journalctl | grep qubesd
^^ Disregard, I just realized that’s where the error came from.

qubesd[2118]: permission denied for call b'admin.backup.Info'+b'/root/.config/qubes-manager-backup.conf' (b'dom0' -> b'dom0') with payload of 0 bytes

I have the destination usb-drive in qube “personal” with the following permissions:

drwxrwxrwx root root

I have the profile under my /etc/qubes/backup/ folder with the following permissions:

-rw-rw-r-- user user

Having said that, how do I change the “group” of the destination USB folder, to “qubes” ? Does such a user already exist in that qube?