ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > Computer Systems > Desktop Computers

Reply
 
LinkBack Thread Tools Display Modes
Old 03-02-2008, 03:50 PM   #1 (permalink)
Bronze Member
 
Join Date: Aug 2004
Age: 21
Posts: 27
Default Backups?

Hey

I turned an old pc into a little file server, I appart from the OS partition I have two main backup partitions on two separate disks. I want to mirror the two partitions but I dont really wanna do it with raid, are there any other solutions? I was thinking about building a cron job or something, but what if I only added a single new file?

any help

Cheers
Joe2003 is offline   Reply With Quote


Old 03-03-2008, 01:30 AM   #2 (permalink)
Platinum Member
 
munkyeetr's Avatar
 
Join Date: Mar 2007
Location: Victoria, BC Canada
Age: 34
Posts: 628
Default

You mentioned a cron job, so may I assume you are running a *nix OS?

I do the same type of thing; I have a bash script that:

1) Backs up my /etc /boot /home /usr/local /var/log directories and compresses the backups
2) Mounts whatever partitions I backup to
3) Copies the compressed backups to the mounted partition
4) Runs a bunch of system reports and stores them to the mounted partition so I know the state of the system at the time of the backup
5) Unmounts the backup partitions

I run this every night at midnight under a root cron job. Works beautifully
__________________
If the advice you receive helps, please post a reply saying so as courtesy to others who will come here with the same problem.

MSI MS-7032 MB - Sempron 3000+ 1.8Ghz - 2GB PC3200
500GB Western Digital - 80GB Samsung - 80GB Maxtor (Dualbooting Ubuntu 7.10/Debian Lenny)
nVidia GF 5700LE 256MB (AGP) - SoundBlaster 24bit PCI
LiteOn DVDRW - Acer AL1916W 19" (2x)
Registered Linux User: 448689

Last edited by munkyeetr; 03-03-2008 at 01:34 AM.
munkyeetr is offline   Reply With Quote
Old 03-03-2008, 01:42 AM   #3 (permalink)
Platinum Member
 
munkyeetr's Avatar
 
Join Date: Mar 2007
Location: Victoria, BC Canada
Age: 34
Posts: 628
Default

In case you were curious, here's the code:

The actual script starts at the bottom of the code, the rest are the functions that make it work.

Code:
#!/bin/sh

# Filename:	backup.sh
# Description:	Runs an automated backup of system and user files
# Arguments:	None
# Author:	munkyeetr
# Date:		Completed on 05/15/07
#----------------------------------------------------------

## START FUNCTION DECLARATIONS AND DEFINITIONS
#----------------------------------------------------------

# Funct Name:	MountVolume()
# Description:	Passed a path, it will test if the path is mounted
#		and if not, it will attempt to mount the path.
# Arguments:	${vol} - path to mount
# Returns:	n/a
#----------------------------------------------------------
MountVolume() {

	vol=$1

	mount | grep "on ${vol} type" > /dev/null
	if [ $? -eq 0 ]; then
		echo ${vol}" is already mounted"
	else
		sudo mount ${vol}
	fi
}

# Funct Name:	UnmountVolume()
# Description:	Passed a path, it will test if the path is mounted
#		and if it is, it will attempt to unmount the path.
# Arguments:	${vol} - path to unmount
# Returns:	n/a
#----------------------------------------------------------
UnmountVolume() {

	vol=$1

	mount | grep "on ${vol} type" > /dev/null
	if [ $? -eq 0 ]; then
		sudo umount ${vol}
	else
		echo ${vol}" is already unmounted"
	fi	
}

# Funct Name:	CreateBackup()
# Description:	Backs up important system folders and the user's
# 		Home directory to ${dest}
# Arguments:	${dest} - path to backup directory
# Returns:	n/a
#----------------------------------------------------------
CreateBackup() {
	
# set backup destinations; create folder
#----------------------------------------------------------
	dest=${1}"/"`date +%m-%d-%y`
	sudo mkdir ${dest}

# backup select filesystems
#----------------------------------------------------------
	source="/etc"
	sudo tar -zcf ${dest}"/etc".tar ${source}

	source="/boot"
	sudo tar -zcf ${dest}"/boot".tar ${source}

	source="/home"
	sudo tar -zcf ${dest}"/home".tar ${source}

	source="/usr/local"
	sudo tar -zcf ${dest}"/usr-local".tar ${source}

	source="/var/log"
	sudo tar -zcf ${dest}"/var-log".tar ${source}

# generate system reports
#----------------------------------------------------------
	dest=${dest}"/reports"

	sudo mkdir ${dest}

	sudo dpkg --get-selections | grep -v deinstall > installed-packages
	sudo mv installed-packages ${dest}

	sudo uptime > system-uptime
	sudo mv system-uptime ${dest}

	sudo ps aux > system-processes
	sudo mv system-processes ${dest}

	sudo ifconfig > system-ifconfig
	sudo mv system-ifconfig ${dest}

	sudo fdisk -l > system-fdisk
	sudo mv system-fdisk ${dest}

	sudo df -l > system-df
	sudo mv system-df ${dest}
}

#----------------------------------------------------------
## END FUNCTION DECLARATIONS AND DEFINITIONS

## SCRIPT BEGINS HERE
#----------------------------------------------------------

backup_locations=( /media/Backup1	  ## < additional backup locations can be put here >
		   /media/Backup2 )	

# cycle through each backup location and perform the backup
for location in ${backup_locations[@]}
do
	MountVolume ${location}
	CreateBackup ${location}
	UnmountVolume ${location}	
done

#----------------------------------------------------------
## SCRIPT ENDS HERE

exit
__________________
If the advice you receive helps, please post a reply saying so as courtesy to others who will come here with the same problem.

MSI MS-7032 MB - Sempron 3000+ 1.8Ghz - 2GB PC3200
500GB Western Digital - 80GB Samsung - 80GB Maxtor (Dualbooting Ubuntu 7.10/Debian Lenny)
nVidia GF 5700LE 256MB (AGP) - SoundBlaster 24bit PCI
LiteOn DVDRW - Acer AL1916W 19" (2x)
Registered Linux User: 448689
munkyeetr is offline   Reply With Quote
Old 03-03-2008, 05:12 AM   #4 (permalink)
Gold Member
 
dougland's Avatar
 
Join Date: Sep 2007
Posts: 382
Default

i clicked this thinking it would be a simple post, way over my head.
dougland is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External Backups fstab Computer Accessories 1 07-07-2006 05:30 PM
RAID Vs. Multiple Backups dillon157 Computer Memory and Hard Drives 10 06-30-2006 01:50 PM
Backups The Astroman General Computer Chat 3 02-11-2006 02:12 PM
XBOX Game Backups Apokarteron General Software 16 12-25-2005 11:52 PM
backups for xbox Bigshow1030 Computer Games and Consoles 4 03-22-2005 06:25 AM


All times are GMT +1. The time now is 03:09 PM.


Powered by: vBulletin Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Copyright © 2002-2007 Computer Forum and Web Design Forum