这是indexloc提供的服务,不要输入任何密码
Skip to content

HLFCode/pibackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pibackup

Bash scripts to backup and restore used space only (not the entire sd card)

These are simple wrappers for bash dd to backup (and restore) only the partitions (as declared by fdisk) to an image file.

This image file can be used by the Raspberry Pi Imager or the restore script to create a copy of the backed up system on a new sd card.

Background

Sometimes it is useful to have more than the Raspberry Pi default of two partitions (boot and system).

A third partition is useful if you want to use a read-only system file system BUT retain a user home space as read-write.

The backup wrapper command checks the last used sector on the sd card and instructs dd to copy up to that sector - no matter how may partitons there are on the sd card

Usage

Backup & restore will usually be done on a separate Pi (or VM) with the sd card to be backed up accessible through an sd card/USB adapter.

The image file to be created can be on the Pi/VM or a mounted network image as needed

Backup

Usage: backup.sh --device <device to backup> --image <image to backup to> [--compress] [--blocksize <size>]
        (-d | -- device <device>)    The device to backup (required)
        (-i | --image <image>)       The file to backup to (required)
        (-c | --compress)            Compress the backup file (optional, default no compression)
        (-bs | --blocksize <size>    The block size in bytes to use (optonal, default is 65536). Pick a size divisible by the sector size
        (-h | -- help)               Print this help
        (-v | --version)             Print the version

The device will normally be /dev/sda if a USB adapter is used.

The --compress option compresses the image on the fly into a file .gz so if the image is backup.img the file created will be backup.img.gz and contain backup.img

Restore

Usage: restore.sh --device <device to resore to> --image <image to backup from>
        (-d | -- device <device>)    The device to restore to (required). Use /dev/null to test
        (-i | --image <image>)       The file to backup from. It can be a gzip compressed file (required)
        (-bs | --blocksize <size>    The block size in bytes to use (optonal, default is 65536)
        (-k | --keepmounted)         If compressed source image, do not unmount it when finished
        (-h | -- help)               Print this help
        (-v | --version)             Print the version

The parameters are the same as for backup.sh

Compressed images

Compressed images will be mounted by archivemount on a local folder (/tmp/compressed) before the data transfer starts.

Note: if the compressed file is on a network drive the mount will be slow as archivemount reads the entire compressed file to ascertain the compressed size.

If --keepmounted is present the uncompressed image will not be dismounted after the restore.

About

Bash commands to backup and restore used space only (not the entire sd card)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages