Jump to content

Backup Help


eyeh8windows
 Share

Recommended Posts

When I do backups using the backup program that came with Mandriva, it leaves behind text files along with the tar'ed files. What purpose do the text files serve? Konqurer says I don't have permission to read them, even the files that appear to be from my account.

 

Many of those files appear to be from diff and incremental backups; I don't even do those types of backup anymore and would like to delete those text files if they are not needed now.

 

Can anyone suggest a better backup program?

Edited by eyeh8windows
Link to comment
Share on other sites

What is it you are backing up? You could create a script to do it, it's really easy, and then even schedule it to run each day on the system. I have a script already if you want it :P

Link to comment
Share on other sites

If you're into incremental backup, this is my prefered link:

http://mikerubel.org/computers/rsync_snapshots/index.html

 

I did not try (shame on me: I have no backup, except when I know I'm going to take some risks), but I'm dreaming of doing so.

I didn't have time to look further, but this may make the process easier:

http://www.pollux.franken.de/hjb/rsback/

 

Yves.

Link to comment
Share on other sites

  • 8 months later...
What is it you are backing up? You could create a script to do it, it's really easy, and then even schedule it to run each day on the system. I have a script already if you want it :P

 

Hi! I also new to Linux, and am planning to migrate from Windows. I have windows xp installed on a partitioned drive, and Mandriva One Spring 2007 on another part of the same drive.

 

Firstly, I having lots of trouble backing up. I´ve run drakbackup, attempting to create a backup cd-rw or dvd, both with no success. Drakbackup just couldn´t get it onto the media. Did everything else, but not that. Also, when I open the Mandriva COntrol Centre and go into system, then to ?onfigure backups of the system and users data' I can´t run that program. My cursor simply hovers over it, and I can´t click on anything. I´ve changed it to the expert mode, and while there are more icons, the only change is I can´t click to open a concole either... any idea what? going on? Anyway, I want to backup my system configuration files, and my home directory. mainly. I´m still experimenting with Mandriva, and learning Linux, and am expecting to crash the system at some point. Thanks for your help!

 

~Mitchell

Link to comment
Share on other sites

If you're into incremental backup, this is my prefered link:

http://mikerubel.org/computers/rsync_snapshots/index.html

 

I did not try (shame on me: I have no backup, except when I know I'm going to take some risks), but I'm dreaming of doing so.

Said and done B) And tested by the way :)

 

#!/bin/bash
#
# Usage: rsyncSave.sh [-r ROOT] [-p PREFIX] [-n NUMBER]
#					 [-a ALTERNATE_PREFIX]
#					 [-o LOGBASENAME] [-v|-l|-q] [-h]
#
# Creates a snapshot named "ROOT/PREFIX`date +%F_%H.%M`" and
# check there are no more than NUMBER directories named that way.
# The snapshot is made from files and directories (recursive)
# taken from places linked to (symbolic) in the directory named "ROOT/PREFIX".
# ROOT: Directory containing all the snapshots.
# PREFIX: Prefix ("daily=", "weekly:", "monthly-"...).
# NUMBER: Number of snapshots allowed of this kind (prefix + date).
# Default values: -r /var -p 'daily-' -n 7
#
# Operations are logged into "ROOT/PREFIX`date +%F_%H.%M`/LOGBASENAME".
# LOGBASENAME: Name of the logfile inside the new snapshot directory.
# -v: Verbose log: rsync -v, and most steps are logged.
# -l: Normal log: normal rsync, and other steps are not logged.
# -q: Quiet log: rsync -q, and other steps are not logged.
# Default values: -l -o snapshot.log
# Errors are always printed.
#
# A new snapshot is created by first hard-linking files from the previous
# snapshot from the same prefix. If no such snapshot is found but an
# ALTERNATE_PREFIX is provided, then the same is attempted using the last
# snapshot from this alternate prefix.
# Whatever source is used, the prepared snapshot is then updated using
# rsync.
#
# This help is printed with -h, or in case of an error.
#
#	  (c) Yves GABLIN - 2007.
#	  This program is free software; you can redistribute it and/or modify
#	  it under the terms of the GNU General Public License as published by
#	  the Free Software Foundation; either version 2 of the License, or
#	  (at your option) any later version.
#
#	  This program is distributed in the hope that it will be useful,
#	  but WITHOUT ANY WARRANTY; without even the implied warranty of
#	  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	  GNU General Public License for more details.
#

DEFAULT_ROOT=/var
DEFAULT_PFX=daily-
DEFAULT_NB=7
DEFAULT_LOG=snapshot.log
DEFAULT_LOGLVL=1

# sensitive commands (avoid aliases)
LS=/bin/ls
RM=/bin/rm
CP=/bin/cp
MKDIR=/bin/mkdir
ECHO=/bin/echo

function help() {
sed -n '2,/^$/ s/^#//p' "$0"
exit ${1:-0}
}

while getopts r:p:n:a:o:vlqh opt; do case $opt in
r) root="$OPTARG";;
p) pfx="${OPTARG##*/}";;
n) nb="$OPTARG";;
a) altpfx="${OPTARG##*/}";;
o) log="${OPTARG##*/}";;
v) loglvl=2;;
l) loglvl=1;;
q) loglvl=0;;
h) help;;
esac; done

root="${root:-$DEFAULT_ROOT}"
pfx="${pfx:-$DEFAULT_PFX}"
nb="${nb:-$DEFAULT_NB}"
log="${log:-$DEFAULT_LOG}"
loglvl="${loglvl:-$DEFAULT_LOGLVL}"
now=$(date +%F_%H.%M)
dir="${pfx}${now}"

# $1: error code; $2...: message
function error() {
exitCode=$1
shift
$ECHO "$@" >&2
help $exitCode >&2
}

# $1...: message
function debug() {
[ $loglvl -gt 1 ] && $ECHO -e "$@"
}

# $1: root directory; $2: prefix
function listSnapshots() {
pushd "$1" &>/dev/null
$LS -1d "$2"[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]_[0-2][0-9].[0-6][0-9] 2>/dev/null
local ret=$?
popd &>/dev/null
return $ret
}

if [ ! -d "$root" ] || [ ! -w "$root" ]; then
error 1 "$root is not a writable directory."
fi
if [ ! -d "${root}/${pfx}" ] || [ ! -r "${root}/${pfx}" ]; then
error 2 "${root}/${pfx} is not a readable directory."
fi
if [ -e "${root}/${dir}" ]; then
error 3 "$dir already exists."
fi
if [ -n "${nb//[0-9]}" ] || [ $nb -eq 0 ]; then
error 4 "$nb is not a valid number (strictly positive integer)."
fi

cd "$root"

if [ $(find "$pfx" -maxdepth 1 -type l -print | wc -l) -eq 0 ]; then
debug "NOTHING TO SAVE (${root}/${pfx}). EXIT."
exit 0
fi

# prepare new snapshot
if listSnapshots . "$pfx" >/dev/null; then
$CP -al "$(listSnapshots . "$pfx" | tail --lines=1)" "$dir"
[ -e "${dir}/${log}" ] && rm -f "${dir}/${log}"
debug "CP PREVIOUS SNAPSHOT ($(date))" | tee "${dir}/${log}"
elif [ -n "$altpfx" ] && listSnapshots . "$altpfx" >/dev/null; then
$CP -al "$(listSnapshots . "$altpfx" | tail --lines=1)" "$dir"
[ -e "${dir}/${log}" ] && rm -f "${dir}/${log}"
debug "CP ALTERNATE SNAPSHOT ($(date))" | tee "${dir}/${log}"
else
$MKDIR "$dir"
debug "CREATE EMPTY SNAPSHOT ($(date))" | tee "${dir}/${log}"
fi
pushd "$dir" &>/dev/null
nodes="$($LS -1ad .* *)"
debug "PREVIOUS NODES:\n$nodes" | tee -a "$log"
while read node; do
if [ ! -e "../${pfx}/${node}" ] && [ "$node" != "$log" ]; then
	$RM -rf "$node"
	debug "DELETED: $node" | tee -a "$log"
fi
done <<<"$nodes"
debug "REMAINING NODES:\n$(ls -1ad .* *)" | tee -a "$log"
popd &>/dev/null

# enforce $nb
if [ $(listSnapshots . "$pfx" | wc -l) -gt $nb ]; then
$RM -rf "$(listSnapshots . "$pfx" | head --lines=1)"
debug "(OLDEST SNAPSHOT DELETED)" | tee -a "${dir}/${log}"
fi

# update new snapshot
case $loglvl in
0) rsyncOpts=("-q" "-a" "--delete");;
1) rsyncOpts=("-a" "--delete");;
2) rsyncOpts=("-v" "-a" "--delete");;
esac
pushd "$pfx" &>/dev/null
saveIFS="$IFS"
IFS=/
find . -maxdepth 1 -type l -printf "%f/%l\n" | while read dest src; do
IFS="$saveIFS"
src="${src%/}"
[ -d "$src" ] && src="${src}/"
debug RSYNC "${rsyncOpts[@]}" "$src" "../${dir}/${dest}" | tee -a "../${dir}/${log}"
rsync "${rsyncOpts[@]}" "$src" "../${dir}/${dest}" 2>&1 | tee -a "../${dir}/${log}"
IFS=/
done
IFS="$saveIFS"
debug "DISK USAGE ($(date)):\n$(df -h)" | tee -a "../${dir}/${log}"
popd &>/dev/null

 

If help (-h) does not help enough (English is not my mother-tongue), don't hesitate to ask for further information.

Basically, you choose a directory (I created /backup on my home computer): this is the "ROOT" of all backups. Then you choose a prefix, eg: "daily-", then you create a directory for this prefix (/backup/daily-) and make symbolic links inside this dir to all things you want to backup. Then you fire crontab -e (or any GUI) and make the script run daily with the right parameters (at my home, this is: -r /backup -p daily- -n 5).

 

I decided, since I created this, I could well use it at work as well, and behold the power of hard links:

[root@ausy_serveur .backup]# for day in jour\=*; do du -ks $day; done; du -ks .
1	   jour=
53856   jour=2007-05-16_20.30
53855   jour=2007-05-17_20.30
568603  jour=2007-05-18_20.30
530293  jour=2007-05-21_20.30
530876  jour=2007-05-22_20.30
724699  .

As you see, the space used by the whole backup (.) is WAY less than the sum of all days ;)

 

Yves.

Edited by theYinYeti
Link to comment
Share on other sites

Interesting. Lots of people seem to be interested in backups today. Here is a quote from a previous thread that I just typed a few minutes ago as a reply to mystified:

 

"Do yourself a favor and check out http://www.mondorescue.org/

 

I've been using this backup for years and it is excellent. It will backup to just about anything. I've used it to restore individual files and also restored back to "bare metal." It does it all. It is already packaged for many different distributions."

 

By the way, it can also do incremental backups, and backup Windows partitions from within Linux.

 

It is available for Mandriva via urpmi.

Edited by RVDowning
Link to comment
Share on other sites

Thanks for the link to MondoRescue. It does seem interesting. It is not the same kind of backup however. Backed-up data is not available as easily, but is usually available longer.

As I see it (and as I use it at work), both methods are complementary (right word?). You can benefit from using both. Eg: I have one week worth of data backup up as I wrote above, and one month worth of data backup up on tape (using tar).

 

Yves.

 

NOTE: I forgot to say: in the above script, don't use the -a ALTERNATEPREFIX option. I tested the whole script except this part; it is an evolution I plan (testing/debugging remains to be done) so that the first weekly backup can be built upon the latest daily one, and the first monthly backup built upon the latest weekly one, and thus to save disk space.

 

NOTE 2: -a ALTERNATEPREFIX is now tested and all is now OK. I've edited the previous post (the script itself) for convenience.

Edited by theYinYeti
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...