Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicholasjackson/bakery
Simple tool to backup and restore ChromeOS Crostini containers
https://github.com/nicholasjackson/bakery
chromeos crostini golang lxc
Last synced: 23 days ago
JSON representation
Simple tool to backup and restore ChromeOS Crostini containers
- Host: GitHub
- URL: https://github.com/nicholasjackson/bakery
- Owner: nicholasjackson
- License: mit
- Created: 2019-01-21T08:11:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-28T07:29:14.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T13:31:17.906Z (5 months ago)
- Topics: chromeos, crostini, golang, lxc
- Language: Go
- Size: 1.3 MB
- Stars: 20
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bakery - Crostini backup and restore tool
Simple tool to backup and restore ChromeOS Crostini containers, influenced by the excelent readme on Reddit
[https://www.reddit.com/r/Crostini/wiki/howto/backup](https://www.reddit.com/r/Crostini/wiki/howto/backup)[![CircleCI](https://circleci.com/gh/nicholasjackson/bakery.svg?style=svg)](https://circleci.com/gh/nicholasjackson/bakery)
## WARNING
* Backup and restore operations can take a long time depending on the size of the container
* The volume used by your Linux installation can grow 3x as the backup and restore process will make a copy of your image, at present it is not possible to resize the volume after temporary files have been cleaned up
* Interuption of the backup and restore process can leave your Linux install in an unstable state, it is recommended to perform this operation while connected to a power source and to set the power when idle to `Keep display on`## Demo Video
[https://www.useloom.com/share/71cdc4055744465f8f467f65cd26db44](https://www.useloom.com/share/71cdc4055744465f8f467f65cd26db44)## Installation
* Open a Crosh terminal using ctrl+alt+t
* Start a new session `vsh termina`
* Copy the backup binary to /mnt/stateful/lxd_confThe latest release can be found, in the `Releases` section, select the correct file for your archictecture.
Example Linux AMD64:
```bash
(termina) chronos@localhost ~ $ curl -L https://github.com/nicholasjackson/bakery/releases/download/v0.1.2/bakery_0.1.2_Linux_amd64.tar.gz -o /mnt/stateful/lxd_conf/bakery.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 639 0 639 0 0 193 0 --:--:-- 0:00:03 --:--:-- 2158
100 752k 100 752k 0 0 138k 0 0:00:05 0:00:05 --:--:-- 660kcd /mnt/stateful/lxd_conf
tar -zxf bakery.tar.gz
```## Backup a Crostini container
A full list of options can be found by running bakery with the help flag```bash
(termina) chronos@localhost /mnt/stateful/lxd_conf $ ./bakery backup --help
Bakery - Crostini Backup and Restore tool
version: v0.1.2Usage of backup:
-archive-container string
Name of the container to write backup files (default "penguin")
-archive-location string
Location of archive files, this is generally the home folder of your current container (default "/home/chronos")
-container string
Name of the container to backup (default "penguin")
-snapshot-prefix string
Prefix of the snapshot to take, snapshots will have time appended to them (default "backup-snapshot")
-termina-location string
```To backup a Crostini container use the following command, replace `container` with your own container name and `archive-location` with the location to store the backup files. Generally this should be something like your home folder so you can copy the files using ChromeOS files:
```bash
(termina) chronos@localhost /mnt/stateful/lxd_conf $ ./bakery backup -container tester -archive-location /home/jacksonnic
Bakery - Crostini Backup and Restore tool
version: v0.1.2Starting backup, WARNING: This operation can take a long time
Creating snapshot of container:tester name:backup-snapshot-52723394
Stopping container tester
Publish container: tester to backup
If the container publish is interupted, your container may be left in a bad state,
in this instance you can restore the snapshot using the command: lxc restore tester backup-snapshot-52723394
Container published with fingerprint: 3b46b83105b3f2da09e70531b41705187cf58cc1e015eb14d1b1a778ef4b962fExporting container to: /mnt/stateful/lxd_conf
Image exported successfully!Splitting backup into 3GB chunks
Starting container tester
Mounting backup path /mnt/stateful/lxd_conf into container penguin
Mount path already existsMoving backup files to /home/jacksonnic in container penguin
Deleting temporary image backup
```The backup files will be output into your `archive-location` folder in 3GB chunks. Once the backup has completed you can move these to external storage for safe storage.
## Restore a Crostini container
A full list of options can be found by running bakery with the help flag```bash
(termina) chronos@localhost /mnt/stateful/lxd_conf $ ./bakery restore -help
Bakery - Crostini Backup and Restore tool
version: v0.1.2Usage of restore:
-archive-container string
Name of the container to read backup files from (default "penguin")
-archive-location string
Location of archive files, this is generally the home folder of your current container (default "/home/chronos")
-container string
Name of the container to restore (default "penguin")
-termina-location string
Location to store temporary backup files in termina (default "/mnt/stateful/lxd_conf")
```To restore a container, first copy your backup archive to a running Crostini container. You can then use the following command replacing the value of the container flag with the name to which you want to restore your backup and the archive-location to the location of your backup files in a running container. Generally this is the home folder.
```bash
(termina) chronos@localhost /mnt/stateful/lxd_conf $ ./bakery restore --container restore -archive-location /home/jacksonnic
Bakery - Crostini Backup and Restore tool
version: v0.1.2Starting restore, WARNING: This operation can take a long time
Mounting backup path /mnt/stateful/lxd_conf into container penguin
Mount path already existsMoving backup files from /home/jacksonnic in container penguin
Merge backup files back into a single archive /mnt/stateful/lxd_conf/backup.tar.gz
importing backup /mnt/stateful/lxd_conf/backup.tar.gz to image backup
Image imported with fingerprint: 3b46b83105b3f2da09e70531b41705187cf58cc1e015eb14d1b1a778ef4b962fInitializing container restore from image backup
Creating restoreDeleting backup image backup
```If you are restoring the default `penguin` instance you can now remove the temporary container and rename your restored container.
```
lxc delete penguin --force
lxc rename restore penguin
```## Testing
To test `backup` use an empty temporary container, this can be created using the following steps:```bash
(termina) chronos@localhost /mnt/stateful/lxd_conf $ lxc init 980e37d286ad tester
Creating tester
(termina) chronos@localhost /mnt/stateful/lxd_conf $ lxc start tester
```You can delete the temporary container using the following command
```bash
lxc delete tester --force
```