Page 1 of 15

Posted: Sun 31 Dec 2006, 06:23
by Gn2
A suggestion - Use cron to sync or backup as needed.
No need to backup all - just the changes.
Use (diff) in any script.

Posted: Sun 31 Dec 2006, 15:45
by zigbert
Thanks for info, shankargopal.
Your methode sounds interesting, and I'll put it into the manual. (will be made some time before 1.0).

But I wonder if PuppyBackups filetree fits your needs. PuppyBackup with mirrorfunction makes the path '/any_savepath/mirrordir1/*'. The mirrordir directory are made, so user knows that this is not original files. In your case maybe the mirrordir directory will come in your way. Maybe it should not been there at all.

Posted: Mon 01 Jan 2007, 05:55
by shankargopal
zigbert,

I'm a little confused - I haven't actually used either PuppyBackup or PuppyMirror, preferring to stick for the moment to my script. So not sure if that directory would get in the way or not - though I don't see why it should. My method is basically this:

1. On the systems where I want to back up, I create an image file with an ext2 filesystem (named pupback.bak) on a suitable partition.
2. Run small script at start up to check all possible hard drive partitions for such an image file.
3. If such an image file exists, mount it every xx seconds (after an initial delay to give possibility of restoring backup if need be) and rsync it with certain directories as specified in a config file.
4. Ensure during shutdown that a final mirror is done.

That's it, really. I can post my makeshift script if you'd like, though I'm embarassed at showing it to any of y'all... :)

Posted: Mon 01 Jan 2007, 12:24
by zigbert
shankargopal

If I understand you right, we are talking about a kind of "realtime" backup. Every backup system should have that feature, shouldn't it? :D In basic, that is not too difficult to put into existing PuppyBackup. The challenge is more how to set things up in existing GUI. We are now talking about a mix of PuppyBackup and crontab, and I try to keep focus on an easy-to-use backup. But in some future, like a flash from nowhere, everything seems clear. (Or, the other way - someboby posts a brilliant soultion on the Puppy forum) :wink:

Please show your script, show all of them...feedback is how we learn. Since my script can't do this task, your script could be a solution for others, or be an example of how to expand usage of PuppyBackup. That could be a part of the coming manual.

Posted: Tue 02 Jan 2007, 03:04
by shankargopal
Sigh, here it is...

The main script that does the backing up - doesn't use cron, just sleeps for 60 seconds between back ups - is below.

Code: Select all

#!/bin/bash
if [ ! -f /root/.PUPBKDRV ]; then
	echo "ERROR. Could not locate .PUPBKDRV"
else
	COUNT=0
	while [ 1 -eq 1 ]; do
	# This if statement allows calling program to specify an initial delay or have this be a "final" run
	# i.e. just one run and then exit
	if [ "$COUNT" -eq 0 ] && [ "$1" != "" ]; then
		if [ $1 != "final" ]; then
				sleep $1
		else
			echo "Final backup running..."
		fi
	else
		sleep 60
	fi
	echo junga > /tmp/backup.running
	BACKPART="`cat /root/.PUPBKDRV`"
	BACKPARTFS="`probepart | grep $BACKPART | cut -f 2 -d "|"`"
	if [ ! $BACKPARTFS = "" ]; then
		[ ! -e /mnt/pupback ] && mkdir /mnt/pupback
		MOUNTED="`mount | grep $BACKPART | cut -f 3 -d " "`"
		if [ "$MOUNTED" = "" ]; then
			mount -t $BACKPARTFS $BACKPART /mnt/pupback
			if [ ! $? -eq 0 ]; then
				echo "Failed to mount backup partition"
				exit
			fi
			MOUNTED="/mnt/pupback"
		fi
		[ ! -e /mnt/backdatafile ] && mkdir /mnt/backdatafile
		mount -o loop -t ext2 $MOUNTED/pupback.bak /mnt/backdatafile 
		if [ $? -eq 0 ]; then
			echo "+++++++++++++++++++++++++++"
			echo "Starting Backup at"
			date
			DIRS="`cat /root/.BACKDIRS | tr "\n" " "`"
			if [ ! "$DIRS" = "" ]; then
				for DIR in $DIRS; do
					ACTDIR="`echo $DIR | sed -r "s/^\///" | sed -r "s/\/$//"`"
					if [ ! -e /mnt/backdatafile/$ACTDIR ]; then
						PATHSPLIT="`echo $ACTDIR | sed -r "s/\// /g"`"
						TOTPATH=""
						for PATHS in $PATHSPLIT; do
							TOTPATH="$TOTPATH/$PATHS"
							mkdir /mnt/backdatafile/$TOTPATH
						done
					fi 
					rsync -a -v --delete /$ACTDIR/ /mnt/backdatafile/$ACTDIR/
				done
			else
				echo "Can't find /root/.BACKDIRS"
			fi
			sync
			umount /mnt/backdatafile
			sleep 3
			[ "$MOUNTED" = "/mnt/pupback" ] && umount /mnt/pupback
		else
			echo "Could not mount backup file"
		fi
	else
			echo "Could not locate backup partition"
	fi
	rm /tmp/backup.running
	echo "==========================="
	let "COUNT+=1"
	if [ $1 = "final" ]; then
		exit
	fi
	done
fi
This script is called from this smaller script, which is called from rc.local on startup:

Code: Select all

#!/bin/bash
POSSPART=`probepart | grep --extended-regexp "vfat|msdos|ext2|ext3|ntfs" | grep --extended-regexp "hda|sda" | cut -f 1 -d "|" | tr "\n" " "`
if [ ! "$POSSPART" = "" ];then
	echo "Searching for pupback.bak on $POSSPART"
	killall pupbacker.sh 2> /dev/null
	for PARTI in $POSSPART; do
	    echo "Checking on $PARTI..."
	    if [ -e /mnt/pupback ]; then
			umount /mnt/pupback 2> /dev/null
		else
			cd /mnt
			mkdir pupback
		fi
		PARTFS=`probepart | grep $PARTI | cut -f 2 -d "|"`
		mount -t $PARTFS $PARTI /mnt/pupback
		if [ $? -eq 0 ]; then
				if [ -e /mnt/pupback/pupback.bak ]; then
					echo "Detected pupback.bak on $PARTI"
					echo -n "Checking if pupback.bak can be mounted..."
					if [ -e /mnt/backdatafile ]; then
						umount /mnt/backdatafile 2> /dev/null
					else
						cd /mnt
						mkdir backdatafile
					fi
					mount -t ext2 -o loop /mnt/pupback/pupback.bak /mnt/backdatafile
					if [ $? -eq 0 ]; then
						echo "success"
						umount /mnt/backdatafile 
						umount /mnt/pupback 
						echo $PARTI > /root/.PUPBKDRV
						echo "Starting PupBacker..."
						/root/Software/pupbacker.sh 300 > /root/Software/backup.log 2> /root/Software/backup.log &
						echo "YOU HAVE FIVE MINUTES TO RESTORE ANY BACKUP.TO GET MORE TIME, KILL pupbacker.sh"
						exit
					else 
						echo "FAILED to mount pupback.bak."
						umount /mnt/backdatafile
						umount /mnt/pupback
					fi
		      fi
			umount /mnt/pupback
		fi
	done
	echo "Failed to find pupback.bak"
	
else
	echo "Could not find any suitable partitions for backups"
fi
Finally, Ihave edited rc.shutdown to check if pupbacker is running, and if so to wait until it completes, or else to call "pupbacker.sh final".

I know there are a lot of hamhanded bits in both scripts, but please note I was writing with a lot of inexperience... this was almost a year ago.

Posted: Thu 04 Jan 2007, 06:33
by zigbert
version 0.7, see mainpost.

shankargopal.
Thank you for sharing your scripts.

Posted: Sun 07 Jan 2007, 01:26
by zigbert
Version 0.8. See main post.

Posted: Tue 09 Jan 2007, 18:06
by zigbert
Version 0.9. See main post.

Posted: Tue 16 Jan 2007, 20:45
by zigbert
version 0.9.4. See main post.

Now I really need testers.

Posted: Wed 17 Jan 2007, 01:33
by MU
0.9.4 already... you're just too fast ;)
Currently uploading Muppy 007 with Puppybackup 0.9.0.
But I did not test it myself yet.

Mark

help

Posted: Wed 17 Jan 2007, 02:38
by brad_chuck
The program looks good. When I backup to hardrive from /root/my-documents/School to /root/backup . the files show up then when the "show backup files are in the dir" comes up.

When I hit OK and exit the program the files are not there.

I am using the compress option.

Posted: Wed 17 Jan 2007, 10:42
by zigbert
thank you, brad_chuck

Bug is fixed for next release. A workaround is to copy/move the *.tgz file before closing 'finished box'.

Posted: Wed 17 Jan 2007, 16:33
by zigbert
version 0.9.5. See main post.

MU, do you follow :wink:

Posted: Sat 20 Jan 2007, 08:58
by zigbert
version 0.9.6. See main post.

Posted: Sat 20 Jan 2007, 15:34
by MU
Zigbert, did you forget to attach it?
Or am I getting old and blind? ;)

Thanks, Mark

Posted: Sun 21 Jan 2007, 07:36
by zigbert
Ooophs :oops:

Posted: Wed 24 Jan 2007, 19:50
by zigbert
Stable Version 1.0.0 and 1.8.0 development release is uploaded. See main post.

Posted: Mon 29 Jan 2007, 18:56
by zigbert
version 1.9.0. See main post.

Posted: Wed 31 Jan 2007, 10:10
by zigbert
version 1.9.1. See main post.

Posted: Thu 01 Feb 2007, 07:10
by zigbert
version 1.9.2. See main post.