Backup and Restore the complete file system

Ask questions about Arch Linux ARM. Please search before making a new topic.

Re: Backup and Restore the complete file system

Postby pentolino » Fri Oct 19, 2012 3:58 pm

I will make a few recovery tries (hope I don't have to do a proper one for a long time!); this should be quick enough for me, since I am not loosing money or risking lives :-)

Thanks for your help
pentolino
 
Posts: 16
Joined: Sun Feb 27, 2011 10:31 am

Re: Backup and Restore the complete file system

Postby maxim » Sat Oct 27, 2012 10:01 pm

Thanks eljohnsmith and slycat for this great script and idea! Works really good.

I modified the perform-the-backup-part, so you don't have to recreate the directories when you restore. I also added /tmp and /run to the exclude option, because they're also populated at boot.

And removed the verbose flag :)

Thanks again!

$this->bbcode_second_pass_code('', '
#! /bin/bash
# script to create a tar backup file
# of the pogo plug device

# directory to place backups
BACKUPDIR=/media/mybook/backup/POGO

# file name YYYY-MM-DDHH:MM:SS.tgz
BACKUPNAME=`date +%F%T`.tgz

# remove dashes and colons from file name
BACKUPNAME=${BACKUPNAME//[-|:]/}

# root directory for the backup
SOURCE=/

# number of sets to keep
NUMSETS=5

# perform the backup
tar -cpzf $BACKUPDIR/$BACKUPNAME \
--exclude=/proc/* \
--exclude=/mnt/* \
--exclude=/sys/* \
--exclude=/dev/* \
--exclude=/tmp/* \
--exclude=/run/* \
--exclude=/lost+found \
--exclude=/media/* \
$SOURCE

# delete older files greater than $NUMSET
cd $BACKUPDIR
LINS=$((NUMSETS + 1))
if [[ $(ls $BACKUPDIR | wc -l) > $NUMSETS ]]
then
stat -c "%Y %n" * | sort -rn | tail -n +"$LINS" | \
cut -d ' ' -f 1 --complement | xargs -d '\n' rm
fi

')
PogoPlug v2 Pink, w/ transmission, flexget, nfs, owncloud..
maxim
 
Posts: 9
Joined: Sun Jun 19, 2011 7:25 pm

Re: Backup and Restore the complete file system

Postby jerry0000 » Sun Dec 23, 2012 5:38 pm

This script works nicely, however gives the leading "/" warning. :)
jerry0000
 
Posts: 57
Joined: Tue Dec 11, 2012 5:38 am

Re: Backup and Restore the complete file system

Postby kochin » Wed Jan 09, 2013 8:17 pm

In order to get rid of those annoying "tar: Removing leading `/' from member names" warnings, I had to modify the tar command to become
$this->bbcode_second_pass_code('', 'tar -C $SOURCE -cpzf $BACKUPDIR/$BACKUPNAME \
--exclude=proc/* \
--exclude=mnt/* \
--exclude=sys/* \
--exclude=dev/* \
--exclude=tmp/* \
--exclude=run/* \
--exclude=lost+found \
--exclude=media/* \
`ls $SOURCE`')
kochin
 
Posts: 1
Joined: Wed Jan 09, 2013 8:09 pm

Previous

Return to User Questions

Who is online

Users browsing this forum: No registered users and 4 guests