Welcome to Gaia! ::

The Official Linux Users of Gaia

Back to Guilds

A Guild for Linux, BSD, Mac, Solaris, and other Unix like operating systems. 

Tags: Computer Help, Linux, BSD (Berkeley Software Distrobution), Mac (Macintosh), Unix 

Reply Programming and Scripting
View my Source!

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

vendion Gear
Captain

PostPosted: Wed Mar 12, 2008 8:43 am


If you have a program that you are excited about or just a piece of code, then post it here commenting about what it does and how it works and others can share their comments about your code or program, and you never know this might inspire other people to do something even better, this is the beauty of open source programs and how they inspire other people to write other programs.
PostPosted: Fri Mar 14, 2008 4:56 pm


I'll be the first to post a program here xd , this is a bash shell script to back up a system to pretty much any kind of location and/or device, and capable of full and incremental backups.
#!/bin/sh

# Backup - create either a full or incremental backup of a set of
# defined directories on the system. By default, the output
# file is saved in /tmp with a timestamped filename, compressed.
# Otherwise, specify an output device (another disk, a removable).

# Help and usage sections, this is a bit lacking...
usageQuit()
{
cat << "EOF" >&2
Usage: $0 [-o output] [-i|-f] [-n]
-o lets you specify an alternative backup file/device
-i is an incremental or -f is a full backup, and -n prevents
updating the timestamp if an incremental backup is done.
EOF
exit 1
}

# program settings
compress="bzip2" # change for your favorite compression app
inclist="/tmp/backup.inclist.$(date +%d%m%y)"
output="/tmp/backup.$(date +%d%m%y).bz2" # default output is /tmp, but can be changed to other devices including, external HDD, CD/DVD writer, FTP server, etc...
outputdevice="/tmp" #the device to backup to (same as above, just without the "/backup.$(date+%d%m%y).bz2
tsfile="$HOME/.backup.timestamp" #Backup timestamp, needed to do a incremental backup
btype="incremental" # default to an incremental backup
noinc=0 # and an update of the timestamp

trap "/bin/rm -f $inclist" EXIT

while getopts "o:ifn" opt; do
case "$arg" in
o ) output="$OPTARG"; ;;
i ) btype="incremental"; ;;
f ) btype="full"; ;;
n ) noinc=1; ;;
? ) usageQuit ;;
esac
done

shift $(( $OPTIND - 1 ))
# Test to see if the output device is mounted
if [ ! -d $outputdevice ] ; then
clear
echo "Error: The device is not mounted or is not present, can not backup"
exit 1
fi

# If the output device is mounted then start backup
echo "Doing $btype backup, saving output to $output"

timestamp="$(date +%m%d%I%M)"

# Run check for .backup.timestamp file, if not found offer the user to create one for them (running a full backup)
if [ "$btype" = "incremental" ] ; then
if [ ! -f $tsfile ] ; then
echo "Error: No .backup.timestamp file found, can not preform Incremental backup" >&2
echo "Do you want me to make one for you? (y/n) Note: This will run a full backup"
read ans
if [ $ans = "y" ] ; then
find $HOME -depth -type f -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
echo "Your $btype backup is done and is in $output"
touch -t $timestamp $tsfile
echo "Timestamp file has been made"
exit 1
else
exit 1
fi
fi
# Incremental backup
find $HOME -depth -type f -newer $tsfile -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
failure="$?"
echo "Your $btype backup is done and is in $output"
else
# Full backup
find $HOME -depth -type f -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
failure="$?"
echo "Your $btype backup is done and is in $output"
fi

# Test to see if the user wants to update the timestamp and act accordingly
if [ "$noinc" = "0" ] ; then
touch -t $timestamp $tsfile
sleep 5
clear
echo "The timestamp has been updated to:"
date
fi

exit 0

Yea I don't make my code very neat, but it does work and if any one wants to use it, I think that it is well documented enough for anyone to set it up the way they want.

vendion Gear
Captain


Zher
Crew

PostPosted: Fri Mar 14, 2008 9:42 pm


my code is not open-source sweatdrop
PostPosted: Sat Mar 15, 2008 9:52 am


Zher
my code is not open-source sweatdrop
Why not?

vendion Gear
Captain


Zher
Crew

PostPosted: Sat Mar 15, 2008 11:10 am


vendion
Zher
my code is not open-source sweatdrop
Why not?

Because I am a Microsoft fan?
i was just joking. 3nodding
PostPosted: Sat Mar 15, 2008 7:39 pm


You can write closed source apps, even with out being a M$ fan just look at Apple. It just there are advantages to writing open source programs. As Stallman said, "1000 eyes are better than 2".

vendion Gear
Captain


GodFly
Crew

PostPosted: Sun Mar 16, 2008 4:44 am


Nice vendion this bas script looks nice you are bether whit this than me razz he he it looks great razz will try it one day biggrin he he for fun biggrin
PostPosted: Mon Mar 17, 2008 12:36 pm


GodFly
Nice vendion this bas script looks nice you are bether whit this than me razz he he it looks great razz will try it one day biggrin he he for fun biggrin
It does wonders my /home/vendion directory is about 16.3 GB and a full backup only takes up 3.3 Gb

vendion Gear
Captain


vendion Gear
Captain

PostPosted: Thu Jul 17, 2008 6:38 am


vendion
I'll be the first to post a program here xd , this is a bash shell script to back up a system to pretty much any kind of location and/or device, and capable of full and incremental backups.
#!/bin/sh

# Backup - create either a full or incremental backup of a set of
# defined directories on the system. By default, the output
# file is saved in /tmp with a timestamped filename, compressed.
# Otherwise, specify an output device (another disk, a removable).

# Help and usage sections, this is a bit lacking...
usageQuit()
{
cat << "EOF" >&2
Usage: $0 [-o output] [-i|-f] [-n]
-o lets you specify an alternative backup file/device
-i is an incremental or -f is a full backup, and -n prevents
updating the timestamp if an incremental backup is done.
EOF
exit 1
}

# program settings
compress="bzip2" # change for your favorite compression app
inclist="/tmp/backup.inclist.$(date +%d%m%y)"
output="/tmp/backup.$(date +%d%m%y).bz2" # default output is /tmp, but can be changed to other devices including, external HDD, CD/DVD writer, FTP server, etc...
outputdevice="/tmp" #the device to backup to (same as above, just without the "/backup.$(date+%d%m%y).bz2
tsfile="$HOME/.backup.timestamp" #Backup timestamp, needed to do a incremental backup
btype="incremental" # default to an incremental backup
noinc=0 # and an update of the timestamp

trap "/bin/rm -f $inclist" EXIT

while getopts "o:ifn" opt; do
case "$arg" in
o ) output="$OPTARG"; ;;
i ) btype="incremental"; ;;
f ) btype="full"; ;;
n ) noinc=1; ;;
? ) usageQuit ;;
esac
done

shift $(( $OPTIND - 1 ))
# Test to see if the output device is mounted
if [ ! -d $outputdevice ] ; then
clear
echo "Error: The device is not mounted or is not present, can not backup"
exit 1
fi

# If the output device is mounted then start backup
echo "Doing $btype backup, saving output to $output"

timestamp="$(date +%m%d%I%M)"

# Run check for .backup.timestamp file, if not found offer the user to create one for them (running a full backup)
if [ "$btype" = "incremental" ] ; then
if [ ! -f $tsfile ] ; then
echo "Error: No .backup.timestamp file found, can not preform Incremental backup" >&2
echo "Do you want me to make one for you? (y/n) Note: This will run a full backup"
read ans
if [ $ans = "y" ] ; then
find $HOME -depth -type f -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
echo "Your $btype backup is done and is in $output"
touch -t $timestamp $tsfile
echo "Timestamp file has been made"
exit 1
else
exit 1
fi
fi
# Incremental backup
find $HOME -depth -type f -newer $tsfile -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
failure="$?"
echo "Your $btype backup is done and is in $output"
else
# Full backup
find $HOME -depth -type f -user ${USER:-LOGNAME} |
pax -w -x tar | $compress > $output
failure="$?"
echo "Your $btype backup is done and is in $output"
fi

# Test to see if the user wants to update the timestamp and act accordingly
if [ "$noinc" = "0" ] ; then
touch -t $timestamp $tsfile
sleep 5
clear
echo "The timestamp has been updated to:"
date
fi

exit 0

Yea I don't make my code very neat, but it does work and if any one wants to use it, I think that it is well documented enough for anyone to set it up the way they want.


A newer, more improved version can be found here, http://code.google.com/p/backup-light/source/browse/trunk/ backup-light/trunk/backuplight.sh. Note this is directly out of SVN so it may have problems that are not yet solved.
PostPosted: Tue Sep 16, 2008 1:52 pm


does anyone upload programs at Planet Source Code?

cablexx


vendion Gear
Captain

PostPosted: Thu Oct 02, 2008 11:45 am


No I only use Google Code and cli-apps.org
Reply
Programming and Scripting

 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum
//
//

// //

Have an account? Login Now!

//
//