BBB Backup your work

From Klaus' wiki
Revision as of 16:44, 24 November 2016 by Klaus (Talk | contribs)

Jump to: navigation, search

Don't cry! Backup regularly.

The script below has been developed to bakup your work on the BBB.

Create a backup directory on your Centos or other Linux machine. Create this script, you may want to call it backupBBB, and make it executable. Run it regularly!

#!/bin/bash
#
#
# Backup script for the BeagleBone Black.
# Modify to suit your needs
#
# Author:    Klaus Kolle
# Date:      20161124
#
# License:   Free an Open Source - use it on your own risk.
#
# Requirements: Drop your ssh public key on the BBB in order to
# make the process login-free for user root.
#
HOMESRC="/home/klaus"
HOMETAR="BBB-home-backup.tgz"
ROOTSRC="/root"
ROOTTAR="BBB-root-backup.tgz"
ETCSRC="/etc"
ETCTAR="BBB-etc-backup.tgz"
USERNAME="root"
HOST="192.168.7.2"
SUFFIX=`eval date +%y%m%d%H%M`
 
echo "Backing up ${HOMESRC}"
ssh ${USERNAME}@${HOST} "tar zcpf - ${HOMESRC}" |cat - > ${HOMETAR}.${SUFFIX} 2>&1 > /dev/null
 
echo "Backing up ${ROOTSRC}"
ssh ${USERNAME}@${HOST} "tar zcpf - ${ROOTSRC}" |cat - > ${ROOTTAR}.${SUFFIX} 2>&1 > /dev/null
 
echo "Backing up ${ETCSRC}"
ssh ${USERNAME}@${HOST} "tar zcpf - ${ETCSRC}" |cat - > ${ETCTAR}.${SUFFIX} 2>&1 > /dev/null

You'll end up with three tar-balls for the home directory, the root users home directory and the /etc directory, where most configuration takes place. Each tar-ball is date and time stamped, so you'll be able to have several backups lying around in your backup directory.