Git Product home page Git Product logo

rpi.backup's Introduction

rpi.backup

A useful set for backup or restore a Raspberry (locally or remotely).

Rsync

Remote copy of Raspberry partitions 1 and 2 on a running Pi

# boot file system (rpi /boot/) for partition 1
sudo rsync -axv --numeric-ids --rsync-path='sudo rsync' pi@RPI_IP:/boot/ /local/path/boot/

# root file system (rpi /) for partition 2
sudo rsync -axv --numeric-ids --rsync-path='sudo rsync' pi@RPI_IP:/ /local/path/root_fs/

In some case, like backup of databases files, it's should be better to make a snapshot of filesystem before remote copy. The default Raspbian root filesystem ext4 don't allow snapshot but btrfs can do that.

Rpi Tools

A set of tools to use with the Raspberry Pi for manage backup and restore.

Setup

# on Debian like Linux distribution
sudo apt-get install -y dosfstools e2fsprogs pv
sudo ./rpi-tools/setup-rpi-tools.sh

Tool rpi-img-maker

This script auto-build an image file for Raspberry Pi SD card. Build standard 2 partitions cards: fat16/ext4 or fat16/btrfs

Usage of btrfs for linux root filesytem need custom kernel. See: https://www.raspberrypi.org/documentation/linux/kernel/building.md for instructions on custom kernel building and see also "Custom kernel" below.

Usage

remote builder :

sudo rpi-img-maker /local/path/boot/ /local/path/root_fs/ myrpi-20160823.img

locally to an usb key :

sudo rpi-img-maker /boot/ / /path/to/usb-key/myrpi-20160823.img

locally to a remote host with ssh :

# create a mount point and link it to remote target
sudo mkdir -p /mnt/ssh/
sudo sshfs -o allow_other,default_permissions [email protected]:/home/pi/ /mnt/ssh/

# build image to remote file system, name scheme is hostname-yyyymmdd.img
sudo rpi-img-maker /boot / /mnt/ssh/`hostname`-`date +"%Y%m%d"`.img

# unmount remote file system
sudo umount /mnt/ssh/

help :

sudo rpi-img-maker -h

Tool rpi-img-writer

This script write an image file (RAW with or without gzip compress) to a SD card. Since using directly dd can be dangerous this script add some checks like target device is mount ?, target is a block device ?, size matching, y/n confirm...

Usage

without gzip :

sudo rpi-img-writer myrpi-20160823.img /dev/usb-card-device

with gzip (for image with *.gz name writer use on fly gunzip):

sudo rpi-img-writer myrpi-20160823.img.gz /dev/usb-card-device

help :

sudo rpi-img-writer -h

Misc

Custom Pi kernel

When a custom kernel is in use on a Pi, some packages should be hold to avoid kernel overwrite.

# stop packages update
sudo apt-mark hold raspberrypi-bootloader
sudo apt-mark hold raspberrypi-kernel

# check
sudo dpkg --get-selections | grep raspberrypi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.