sebanc / brioche

An alternative to Crostini / Crouton for devices running brunch
GNU General Public License v3.0
72 stars 8 forks source link

Backup the linux container: lxc-snapshot not working #21

Open saturn-hh opened 3 years ago

saturn-hh commented 3 years ago

I changed my daily driver system from Linux to brunch/Chrom OS in combination with brioch/ubuntu and it looks promising to me.

Unfortunatly I can't backup the linux container. I've tried with lxc-snapshot and lxc-copy but without success. Am I missing something her?

If I try to copy the container: lxc-copy --name=ubuntu-lex --newname=ubuntu-lex-copy --newpath=/home/chronos/user/Downloads --logfile=lxc-copy.log --allowrunning --lxcpath=/home/root/brioche/ lxc-copy: ubuntu-lex: storage/storage.c: storage_copy: 494 Failed to rsync from "/usr/local/lib64/lxc/rootfs" into "/home/chronos/user/Downloads/ubuntu-lex-copy/rootfs": lxc-copy: ubuntu-lex: lxc-copy: ubuntu-lex: lxccontainer.c: copy_storage: 3584 Error copying storage. lxc-copy: ubuntu-lex: utils.c: _recursive_rmdir: 161 Inappropriate ioctl for device - Failed to delete "/home/chronos/user/Downloads/ubuntu-lex-copy/rootfs" lxc-copy: ubuntu-lex: utils.c: _recursive_rmdir: 161 Inappropriate ioctl for device - Failed to delete "/home/chronos/user/Downloads/ubuntu-lex-copy" lxc-copy: ubuntu-lex: lxccontainer.c: container_destroy: 3070 Failed to destroy directory "/home/chronos/user/Downloads/ubuntu-lex-copy" for "ubuntu-lex-copy" lxc-copy: ubuntu-lex: tools/lxc_copy.c: do_clone: 358 Failed to clone

If I try to create a snapshot of the container (lxc-snapshot) lxc-snapshot --name=ubuntu-lex -o lxc-snapshot.log --logpriority=1 lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_snapshot: 4166 Snapshot of directory-backed container requested lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_snapshot: 4167 Making a copy-clone. If you do want snapshots, then lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_snapshot: 4168 please create overlay clone first, snapshot that lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_snapshot: 4169 and keep the original container pristine lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_clone: 3785 error: Original container (ubuntu-lex) is running. Use --allowrunning if you want to force a snapshot of the running container. lxc-snapshot: ubuntu-lex: lxccontainer.c: do_lxcapi_snapshot: 4175 Failed to clone of /usr/local/var/lib/lxc:ubuntu-lex lxc-snapshot: ubuntu-lex: tools/lxc_snapshot.c: do_snapshot: 199 Error creating a snapshot

The container ist stopped and the option --allowrunning ist unkonwn?

sebanc commented 3 years ago

I have not really looked into those features, chromeos encryption often blocks lxc from writing to encrypted folders such as "Downloads" which might be the issue here.

In any case, I would suggest to use a custom script to make a compressed archive from the container directory in /home/root/brioche and to restore it when needed.

saturn-hh commented 3 years ago

Reality check! Something (?) removed my container (I have no idea what or way!).

Due to your comment I have had a backup which I manually created a view days before. And: It worked! I had to reinstall brioche and a container with the same name as my real container and copied the backup over the newly created one. Tata: The (backup) container started!

To get the task of preparing the backup a bit more handy, I took a a script from her (https://medium.com/@fotios.floros/linux-backup-script-1722cc9c2bf6) and changed the paths:

#!/bin/bash #typically the first line of the bash scripts BACKUPTIME=date +%b-%d-%y#get the current date DESTINATION=/home/chronos/user/Downloads/YOUR-FOLDER/YOUR-CONTAINER-$BACKUPTIME.tar.gz #create a backup file using the current date in it's name SOURCEFOLDER=/home/chronos/user/brioche/YOUR-CONTAINER #the folder that contains the files that we want to backup tar -cpzf $DESTINATION $SOURCEFOLDER #create the backup REMARKS: Please create the folder in the directory "Downloads" Change YOUR-FOLDER and YOUR-CONTAINER according to the name of your container The script has to be manually started by root, so I placed it in the folder /root after creating the script with nano make it executable (chmod +x SCRIPT-NAME.sh)

This is still a primitive solution due to the fact that one has to start the script as root manually, but I have no clue how to get a more state of the art backup solution under chromeos.

Thank you again for your suggestion to prepare an archive of the container. It saved me a bunch of work for setting up the complete container again.

Alexander