[haiku] Re: Backup strategy for Haiku productive systems

  • From: Matt Madia <mattmadia@xxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Tue, 27 Apr 2010 13:43:19 +0000

On Tue, Apr 27, 2010 at 07:47, beos@xxxxxxxxxxxxx <beos@xxxxxxxxxxxxx> wrote:
> Would it be the best to zip the personal data and copy it to another Haiku
> partition? Or better copy it to a BeOS-generated BFS partition? To a FAT
> partition? Or should I FTP it to my desktop machine to not let Haiku's BFS
> write onto the backup partition directly? How often do you make backups of
> your Haiku data?
>
> What do you suggest, how do you do it?

In addition to the comments, a while back myself, stpere, and others
worked on making a very crude shell script to help backing up files.
Basically, an attribute with a certain value is added to any file or
directory that you want to back up.  The script will then create a zip
containing all of them, which can then later be extracted to boot.

I use mostly for tagging certain settings files that i want to easily
restore on a freshly installed partition (workspaces, keymap, ssh
keys, etc. ..) Eg, my upgrade strategy is to leap frog from one Haiku
partition to another ... this allows me to easily reboot into an older
revision to see if a newly encountered bug exists there as well.

As for backing up code and other similar data, I've a few Mercurial
repositories on my local network.



=-=-=-=
#!/bin/sh

# Synopsis:
#   Certain files||folders will have an attribute on them.
#       This attribute is USER:BKP=0|1
#       A value of "1" indicates the file is to be backed up.
#       A value of "0" is used to exclude a file||folder.
#               eg,     /path/foo = 1
#                       /path/foo/bar/cache = 0
#       The above example should result in archiving all of foo except bar/cache
#       In order to preserve the attribute on folders,
#               the folder itself must be archived and not folder/*
#
#
# `mkindex -t int USER:BKP -d /boot`  is the command for creating the index.
#               This is needed to allow queries to find the files.
#
# `reindex -r USER:BKP /boot` is the command for indexing files that were added
#               prior to the `mkindex` command.
#
# `addattr -t int USER:BKP 1 <files-or-directories>` is the command syntax for
#       tagging files for backup.

mkindex -t int USER:BKP -d /boot
reindex -r USER:BKP /boot
# Set up some variables
timestamp=`date +%Y%m%d%H%M%S`
# Make files relative to /boot/
sedCMD="sed -e 's|/boot/||g'"
queryin="query -e -v /boot USER:BKP=1 | ${sedCMD}"
queryex="query -e -v /boot USER:BKP=0 | ${sedCMD}"
archive=backup-${timestamp}.zip
listin=/tmp/userbkp.include
listex=/tmp/userbkp.exclude
listnor=/tmp/userbkp.norecursion
listtmp=/tmp/userbkp.tmp

# Remove old files
for file in ${listin} ${listex} ${listtmp} ${listnor} ; do
        if [ -e ${file} ] ; then
                rm ${file}
        fi
        touch ${file}
done

# Prepare new files
eval $queryin > ${listin}
eval $queryex > ${listex}

# Directories need "/*" added to them
# Without it, they are not archived by Info-Zip 2.32
# Possibly a bug?

# Items to be included
while read linein ; do
        if [ -d "/boot/${linein}" ] ; then
                echo ${linein}/* >> ${listtmp}
        else
                echo ${linein} >> ${listtmp}
        fi
done < ${listin}
mv -f ${listtmp} ${listin}
touch ${listtmp}

# Items to be excluded
while read lineex ; do
        if [ -d "/boot/${lineex}" ] ; then
                echo ${lineex}/* >> ${listtmp}
                # Record directories with USER:BKP=0
                # They must be added to the archive without:
                #   -r   recurse into directories
                echo ${lineex} >> ${listnor}
        else
                echo ${lineex} >> ${listtmp}
        fi
done < ${listex}
mv -f ${listtmp} ${listex}

# Archive it!
cd /boot
zip -r9y ${archive} -x@${listex} -i@${listin} ./
zip -9y ${archive} -@ < ${listnor}

if [ -e ${archive} ] ; then
        open ${archive} &
fi
=-=-=-=-=

Other related posts: