Backups are currently stored as raw disk images inside compressed SquashFS-containers uploaded to Google Drive.
-
Insert SD card in card reader and make sure you know its device name
- NOTE: If you use the wrong devicename below you might try to overwrite the harddrive in your workstation so be careful and check the devicename!
# lsblk # dmesg | tail -n 50
- Below, instead of sdx, use the real devicename you got in the previous step
-
Create a directory where you would like to save your image (which will be included in the compressed archive in a later step)
$ mkdir sdcard-backup $ cd sdcard-backup
-
Dump the whole SD card to a file together with SHA-256 integrity checksum using pv and tee
(If you need to install the commands on your workstation, use
sudo pacman -S pv tee
)# pv /dev/sdx | tee sdcard.dd | sha256sum > sdcard.dd.sha256 # sed -i 's/-$/sdcard.dd/' sdcard.dd.sha256
OR
-
If you can not install pv and tee the same result can be acheived using dd but without any indication of progress)
# dd if=/dev/sdx of=sdcard.dd # sha256sum sdcard.dd > sdcard.dd.sha256
You can include other data besides the image in the backup archive by adding files in this directory, they will then be included in the archive. For example
fdisk -l /dev/sdx > fdisk-l.txt
or you could edit a note in a textfile. -
-
Compress the archive
-
Exit the working directory where the raw backup output resides
# cd ..
-
Compress the whole directory along with content created in previous steps
This will create a mountable SquashFS-container (mksquashfs can be installed on Arch Linux workstations using
pacman -S squashfs-tools
)# mksquashfs sdcard-backup sdcard-backup-$(date +%F).sqf -comp xz
OR
- create a bzip2-compressed tar-file
# tar cvjf sdcard-backup-$(date +%F).tar.bz2 sdcard-backup
-
-
Clean up by deleting the backup directory
# rm -rf sdcard-backup
-
Create a mountpoint for accessing the contents of the backup archive and mount the SquashFS-archive
$ mkdir backupmnt
-
Mount archive contents in the directory, enter directory and list contents
# mount sdcard-backup-1234-56-78.sqf backupmnt # cd backupmnt # ls -lah
-
Clone the raw dd-image from the archive to the physcial SD card using pv (pipeviewer)
# pv sdcard.dd > /dev/sdx
-
Sync and eject SD card to ensure everything is written to it before removal
# sync # eject /dev/sdx
-
Clean up
# cd .. # umount backupmount # rmdir backupmount