|
|
#1 (permalink) |
|
Bronze Member
![]() Join Date: Aug 2004
Age: 21
Posts: 27
|
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 |
|
|
|
|
|
#2 (permalink) |
|
Platinum Member
![]() Join Date: Mar 2007
Location: Victoria, BC Canada
Age: 34
Posts: 628
|
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. |
|
|
|
|
|
#3 (permalink) |
|
Platinum Member
![]() Join Date: Mar 2007
Location: Victoria, BC Canada
Age: 34
Posts: 628
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |