Re: Killed /home during install of another distro



On Mon, 2007-07-30 at 02:19 +0300, Dotan Cohen wrote:
no way to boot and google the situation, I played Y, Y, Y to all
fsck's questions. Now, /home is empty. I do have a backup from 4 weeks
ago, as I backup the first of every month, but I have done quite a bit
of work this past month. I'm very interested in recovering the data.

You could try looking in /lost+found.

And start backing up every day. It's easy enough to attach a cheap USB
drive and set up a cron job to just rsync /home to it every night. A
simple script will cycle the target directories, and you can have a
week's worth or even a month's worth on that disk, at very little cost
in disk space due to the magic of rsync and hard links.

Modify these scripts appropriately for your needs (especially paths,
DEST, SOURCES etc), put them into $DEST, and tell cron to run the "rb"
script as often as you like. Note that the first run will take a while,
as it has to copy everything. Subsequent runs will be MUCH faster, as
only altered files will be copied, unaltered files will be hard-linked
to.

These scripts assume a local copy, by the way. You could back up to a
remote site pretty easily, but you need to set up a transport (like ssh)
and I'm not sure if the hard-link idea would still work.

Regards, K.


~~~~~~~~~~~~~~~~~ start of backup script ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh

#
# Rotates backups, does a new one.
#

DEST=/media/usbdisk/bu

cd $DEST
if ./r && ./b ; then
exit 0 ;
else
exit 1
fi

~~~~~~~~~~~~~~~~~ start of rotater script ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh

#
# This script rotates a set of backup directories.
#

DEST=/media/usbdisk/bu

# List the backup directories here, in order oldest to youngest.
# These should generally be fully qualified paths.
DIRS="$DEST/backup.07 "
DIRS="$DIRS $DEST/backup.06"
DIRS="$DIRS $DEST/backup.05"
DIRS="$DIRS $DEST/backup.04"
DIRS="$DIRS $DEST/backup.03"
DIRS="$DIRS $DEST/backup.02"
DIRS="$DIRS $DEST/backup.01"
DIRS="$DIRS $DEST/backup.00"

# This function rotates the backup directories. After this function has
# been called, $NEXT contains the name of the directory that should
# receive the new backup, $CURRENT contains the name of the youngest
# backup.
rotate_dirs()
{
# check that all candidates are directories.
for i in $DIRS ; do
{
if [ ! -d $i ] ; then
echo "$i is not a directory!" > /dev/stderr
exit 1
fi
}
done

# move them all "down"
unset $NEXT
for i in $DIRS ; do
{
if [ -z $NEXT ] ; then
NEXT=$i
echo remove oldest directory $i
rm -fr $i
if [ -e $i ] ; then
echo "Can't remove oldest directory!"
exit 1
fi
else
echo rename $i to $NEXT
mv $i $NEXT
if [ -e $i ] ; then
echo "Can't rename $i to $NEXT!" > /dev/stderr
exit 1
fi
CURRENT=$NEXT
NEXT=$i
fi
}
done
}

# Move all the backup directories up one, oldest will be lost.
rotate_dirs

# create $NEXT for this backup
mkdir $NEXT
if [ ! -e $NEXT ] ; then
echo "Can't create new directory $NEXT!" > /dev/stderr
exit 1
fi
if [ ! -d $NEXT ] ; then
echo "$NEXT is not a directory!" > /dev/stderr
exit 1
fi

exit 0

~~~~~~~~~~~~~~~~~ start of rsync script ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/sh

#
# this script backs up all the directories given in SOURCES to DESTINATION,
# hardlinking to the most recent PREVIOUS version.
#
# Note that source directories should be specified with NO trailing slash,
# otherwise their contents will end up in the backup directory directly.
#

SOURCES=""
SOURCES="$SOURCES /home"
SOURCES="$SOURCES /etc/apache2"
SOURCES="$SOURCES /etc/bind"
SOURCES="$SOURCES /usr/share/moin"
SOURCES="$SOURCES /var/www"

DESTINATION=/media/usbdisk/bu/backup.00
PREVIOUS=/media/usbdisk/bu/backup.01

for source in $SOURCES ; do
{
rsync -av --delete --link-dest=$PREVIOUS $source $DESTINATION
}
done

exit 0

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer@xxxxxxxxxxxxxx) +61-2-64957160 (h)
http://www.biplane.com.au/~kauer/ +61-428-957160 (mob)


--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Relevant Pages

  • Feedback on backup script
    ... The one problem I have is that the script keeps stopping at lines 633,635 and or 637 with the error "Path Not Found" I have emailed the original author for help but haven't heard back yet. ... I was just wondering if the problem could be that the account running the script doesn't have correct permissions to a share/directory/file that it's trying to backup? ... ' always one less than the actual number of folders. ... ' Show the user free space info on all available disk drives ...
    (microsoft.public.scripting.vbscript)
  • Re: External Hard drive Problem
    ... Replace my name/directorys with yours and enter the loginscript in you defaults. ... you will have to adjust the volume name of you r BackUp script. ...
    (comp.sys.mac.system)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)
  • Re: xcopy and vbscript
    ... It takes about 5-6 minutes to backup approximately ... A copy of the script is below for reference. ... ObjShell.Popup strMessage, 5, "Backup Complete", OK_Button ... Dim sSrc, sDest ' as string ...
    (microsoft.public.scripting.vbscript)
  • Re: How do I move an account... A few more details... and more
    ... >> use this system as a backup system if the first ever goes down. ... >> rsync for this. ... >serv1 and the system you back up to is fs. ... >rsync script. ...
    (Fedora)