LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-20-2005, 11:48 AM   #1
bhoult
LQ Newbie
 
Registered: Jul 2005
Posts: 6

Rep: Reputation: 0
How tar to backup Linux OS?


I just spent the last few weeks upgrading our company server to Kubuntu. It was quite a pain getting all the services configured and working again so I would not want to start over if the HDD decided to die. I know raid would be nice for this purpose, but some downtime is not a problem... as long as I can get things up and going again in a matter of hours. So what I would like is a script that could run monthly and make a copy of the drive.

I have used partimage in the past, but I believe the fs has to be unmounted at the time which would be a problem if the FS is running on it. It also requires that the replacement drive be partitioned exactly the same as the old one.

My question is if it is possible to just tar the entire filesystem in a weelky script and then restore over a fresh install of Kubuntu if there is a problem. I know some directories such as /proc would need to be dealt with somehow... but I am not sure if I would just exclude it, or if there are other files/directories that would cause problems. Was also not sure if there is any common software that refrences files by inode instead of name as the inodes would all change.
 
Old 07-20-2005, 11:59 AM   #2
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Rep: Reputation: 78
You could tar the bin boot dev etc home opt root sbin usr var each in a serperate file. There are max file size for each partition type. I do this with mine at home and I can restore it in a matter of minutes. This may not be the proper way, but it is the easiest for me. There are comercial apps too that can do, but they tend to cost a bit.
 
Old 07-20-2005, 12:16 PM   #3
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
The only files that change somewhat during normal usage on my system are in /home and /var, I have a script run every day that tars and bzip2s /home, rotate the backups and delete the oldest one. I'm not bothered about /var as that only has logs in it.

Whenever I do a major upgrade to my system I boot knoppix and dd the the system partition to an image file on a storage hdd. In the event of HDD failure or or I break something I can just restore the files from the image file

I did this once whilst still running the system from that hdd and it worked surprisingly well except for a few stray pid files.
 
Old 07-21-2005, 11:37 AM   #4
tangle
Senior Member
 
Registered: Apr 2002
Location: Arbovale, WV
Distribution: Slackware
Posts: 1,761

Rep: Reputation: 78
You could do something like this for your daily script.
Code:
#!/bin/bash

# finds all files that have been added or modified in the last 24 hours and puts
# them in a file named /tmp/filelist.daily
find / -mtime -1 \! -type d -print > /tmp/filelist.daily

# puts the start date and time in a file named date.daily in the tmp directory.
date > /tmp/date.daily

# start portmap service
/etc/rc.d/rc.portmap start

# mounts the network share lazarus on the server named srv3.
mount busrv:/pub/backups /mnt/busrv

# changes the current working directory to root
cd /

# make a tar file with all the files listed in the filelist.daily file


# puts the finish time and date in a file named date.daily in the tmp directory
date >> /tmp/date.daily

# unmounts the the network share on srv3
umount /mnt/busrv

# stop portmap service
/etc/rc.d/rc.pormap stop
And something like this for your weekly backup.


Code:
#!/bin/bash

# Change working directory to / (root).
cd /

# Set the date 
echo "set date variable"
DATE=`date +'%m-%d-%Y'`

# Log start time to /var/log/backup.log.
echo "start backup"${DATE} >> /var/log/backup.log

# Starts the rpc.portmap service used to mount a remote nfs share.
echo "start portmap service"
/etc/rc.d/rc.portmap start

# Mount the remote share named backups on the server named srv3.
echo "mount shared network drive"
mount busrv:/pub/backups /mnt/busrv

# Create a tarball of all files listed in the [todays date]_files file.
echo "creat tarball"
tar cvfz /mnt/busrv/srv1_scripts-${DATE}.tar.gz bin sbin
tar cvfz /mnt/busrv/srv1_boot-${DATE}.tar.gz boot
tar cvfz /mnt/busrv/srv1_etc-${DATE}.tar.gz etc
tar cvfz /mnt/busrv/srv1_home-${DATE}.tar.gz home
tar cvfz /mnt/busrv/srv1_usr-${DATE}.tar.gz usr
tar cvfz /mnt/busrv/srv1_var-${DATE}.tar.gz var
tar cvfz /mnt/busrv/srv1_lib-${DATE}.tar.gz lib
tar cvfz /mnt/busrv/srv1_root-${DATE}.tar.gz root

# Umount remote share.
echo "unmount network drive"
umount /mnt/busrv

# Stop rpc.potmap service.
echo "stop portmap service"
/etc/rc.d/rc.portmap stop

# Change working directory back to /root.
cd
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tar backup TheRealDeal Linux - General 7 02-08-2005 03:25 PM
Using tar for backup. TheRealDeal Linux - General 2 08-10-2004 11:46 PM
Tar Backup Log bally Linux - General 2 04-14-2004 12:24 AM
tar as backup imsajjadali Red Hat 4 02-07-2004 03:46 PM
tar: How do I backup everything !! grantm Linux - Newbie 3 07-30-2003 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration