SearchFAQMemberlist Log in
Reply to topic Page 1 of 1
creating tar archives
Author Message
Post creating tar archives 
hello --

i know that this topic is well trodden, and i did get quite
a bit of info from the archives -- if there's a FAQ i should
read, please be kind. Smile

i want to periodically move a copy of my backed up data out of the
house. i bought a large removeable disk to use for this.

i realize that copying the pool is prohibitively expensive, due
to the number of hard links. i can live with that. (though it was
kind of a surprise, the first time i tried. Smile

so what i want is a script which creates a tarball of the current
state of every share, and copies them to my removeable disk.
using some examples from the archives, i've come up with the
script below. i'd be happy to trade it in for someone else's
well-tested version, and i'd be equally happy to have someone
critique what i've done.

i'm most concerned with my technique for fetching the number of
the most recent backup -- is my egrep/tail/awk going to do the
trick? (i read that this will be available more directly
in 2.1 -- correct?)

is there a more effective way to loop through the shares on all
of my hosts, rather than hard-coding the list as i have done? (i
think i read that this, too, is being addressed in 2.1?)

and is my understanding correct, that BackupPC_tarCreate will
give full contents, whether asked for a full or incremental
backup?

anyway, my script appears below. any comments welcome...

paul
p.s. and, since i'm new on the list: thanks for a _great_ backup
system! i recommend it whenever the topic comes up.
=---------------------
paul fox, pgf < at > foxharp.boston.ma.us (arlington, ma, where it's 34.7 degrees)

-------cut here --------
#!/bin/sh

# mount a specific usb-connected disk on /offsite, create backup
# tarballs there, and unmount


if [ ! -f /proc/scsi/usb-storage-0/1 ]
then
echo no usb device found >&2
exit 1
fi

if ! egrep -q 'Maxtor 5 Model: A300J0' /proc/scsi/scsi
then
echo wrong usb device found >&2
exit 1
fi


if ! mount /offsite
then
echo could not mount sda1 on /offsite
exit 1
fi

# try to ensure we always unmount
trap "umount /offsite" 0


# rotating date-based backup directories -- must be expunged manually
dir=/offsite/bck/$(date +%Y-%m-%d)

if ! mkdir $dir
then
echo could not mkdir $dir
exit 1
fi


# create a tarfile for a share
doit()
{
if [ $# != 2 ]
then
echo doit needs two args: host and sharename
exit 1
fi

host=$1

share=$2
# convert '/' to '-'
sharename=$(echo $share | sed -e 's/\//-/g' -e 's/^-//' )
if [ ! "$sharename" ] # all gone? must have been '/'
then
sharename=root
fi

mkdir -p $dir/$host

back=$(lastback $host)

bin/BackupPC_tarCreate -h $host -n $back -s $share / |
gzip -c > $dir/$host/$sharename.tgz
}

lastback()
{
host=$1
log=/big/backuppc/pc/$host/LOG
egrep '(full|incr) backup [[:digit:]]+ complete' $log |
tail -1 | awk '{print $5}'


}

# enumerate the hosts, and their shares

doit firethorn /
doit firethorn /var
doit firethorn /var2

doit tumbleweed /
doit tumbleweed /boot

doit grass /
doit grass /boot

doit gutso /
doit gutso /boot
doit gutso /usr2
doit gutso /dos


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
BackupPC-users mailing list
BackupPC-users < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/backuppc-users
http://backuppc.sourceforge.net/

Post creating tar archives 
Paul Fox writes:

i want to periodically move a copy of my backed up data out of the
house. i bought a large removeable disk to use for this.

i realize that copying the pool is prohibitively expensive, due
to the number of hard links. i can live with that. (though it was
kind of a surprise, the first time i tried. Smile

so what i want is a script which creates a tarball of the current
state of every share, and copies them to my removeable disk.
using some examples from the archives, i've come up with the
script below. i'd be happy to trade it in for someone else's
well-tested version, and i'd be equally happy to have someone
critique what i've done.

i'm most concerned with my technique for fetching the number of
the most recent backup -- is my egrep/tail/awk going to do the
trick? (i read that this will be available more directly
in 2.1 -- correct?)

is there a more effective way to loop through the shares on all
of my hosts, rather than hard-coding the list as i have done? (i
think i read that this, too, is being addressed in 2.1?)

Yes, these will both be addressed in 2.1. With 2.0.2 you can't do much
better than running egrep/tail/awk on the backups file.

In 2.1.0 you will be able to specify -1 for the backup number,
which means the last (in fact, -n means the nth last backup).

Also, "*" (or really \* for shell escaping) can be specified for the
share name, which causes each share to be included in a single tar
file; this adds one extra level to the archive, eg:

./shareName1/dir/dir/file
...
./shareName2/dir/dir/file

and is my understanding correct, that BackupPC_tarCreate will
give full contents, whether asked for a full or incremental
backup?

Yes, it will always be reconstructed to look like a full.

Also, in 2.1 there will be an archive feature where you can select one
or more or all hosts and have it run BackupPC_tarCreate on each host.
The output goes to a script that you can customize that might write
it to tape, dvd, or another disk.

All of the features I mention for 2.1 are already in CVS if you want
to take a peek.

Craig


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
BackupPC-users mailing list
BackupPC-users < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/backuppc-users
http://backuppc.sourceforge.net/

Post creating tar archives 
is there a more effective way to loop through the shares on all
of my hosts, rather than hard-coding the list as i have done? (i
...
Also, "*" (or really \* for shell escaping) can be specified for the
share name, which causes each share to be included in a single tar
file; this adds one extra level to the archive, eg:

./shareName1/dir/dir/file
...
./shareName2/dir/dir/file

this is good, but it's not quite as flexible as i'd like. i'd
prefer (since they're big) that the shares end up in separate
tarballs. to do that, i need to get an enumeration of those shares.
is there a way to easily get that, without requiring knowledge of
the format of the pc/<host>/config.pl file?

i think a "BackupPC_listShares <hostname>" command would be sufficient.
for added value, perhaps without any args it could list all hosts.

paul
=---------------------
paul fox, pgf < at > foxharp.boston.ma.us (arlington, ma, where it's 41.7 degrees)


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
BackupPC-users mailing list
BackupPC-users < at > lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/backuppc-users
http://backuppc.sourceforge.net/

Post creating tar archives 
Paul Fox writes:

Also, "*" (or really \* for shell escaping) can be specified for the
share name, which causes each share to be included in a single tar
file; this adds one extra level to the archive, eg:

./shareName1/dir/dir/file
...
./shareName2/dir/dir/file

this is good, but it's not quite as flexible as i'd like. i'd
prefer (since they're big) that the shares end up in separate
tarballs. to do that, i need to get an enumeration of those shares.
is there a way to easily get that, without requiring knowledge of
the format of the pc/<host>/config.pl file?

i think a "BackupPC_listShares <hostname>" command would be sufficient.
for added value, perhaps without any args it could list all hosts.

Listing the shares actually depends upon the specific backup in pc/<host>/<num>,
rather than config.pl. That's because you might update config.pl with new
shares, but the existing backups have whatever shares were backed up then.
With the current CVS this would be pretty easy. In CVS the BackupPC::View
module now has a function shareList(). Contributions are welcome Smile.

Craig

Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


Magic SEO URL for phpBB