LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-30-2003, 11:02 AM   #1
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Rep: Reputation: 15
backup and restore using tar


I would like to know your thoghts on this. I am trying to find the best means to backup my entire Web Server to tape on a nightly basis. I feel that tar might be the way to go as I am not quite qualified to write backup scripts yet. Does tar maintain file permissions in the event that a restore is required? I don't want to loose all my file permissions and group ownerships.

How would I create a script using tar to backup the entire Mandrake 9.1 system and where should I store this script so root can perform this?

I will be backing up to /dev/st0

Your thoughts on this are very much welcome.
 
Old 10-30-2003, 12:52 PM   #2
lyx0m
LQ Newbie
 
Registered: Oct 2003
Location: Mexico City
Distribution: gentto 1.4/Mandy 9.2/RedHat 9.0/Solaris/HPUX
Posts: 21

Rep: Reputation: 15
Cool

Hi
The way to backuop anytthing keeping the permisions woulld be:

tar cvpf /dev/st0 <whate_ever_path>, now, if you plan to backup on a daily basis y would suggest to put via cron:
00 23 * * * tar cvpf /dev/st0 /etc/httpd /var/www
this will allow you to backup automatically at 11pm everyday.

If you want to backup an entire system, I wond use another disk ass mirror and would type

dd if=<disk_device> bs=1024 of=<your_mirror_disk_device>

or you can send it to tape:

tar cvpf /dev/st0 / /etc /usr /var /tmp /opt /sbin (it depends how did you create your partitions and how big they are)
lyx0m
 
Old 10-30-2003, 01:04 PM   #3
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Original Poster
Rep: Reputation: 15
here is my disk structure.
Filesystem Size Used Avail Use% Mounted on
/dev/hda5 3.9G 1.8G 2.0G 49% /
/dev/hda1 46M 8.7M 35M 20% /boot
/dev/hda6 9.7G 49M 9.7G 1% /home
/dev/hda7 3.8G 422M 3.2G 12% /var
/dev/hdb1 19G 781M 17G 5% /var/www

I wish I could mirror but I dont see how with the way the system is configured.
 
Old 10-30-2003, 01:14 PM   #4
lyx0m
LQ Newbie
 
Registered: Oct 2003
Location: Mexico City
Distribution: gentto 1.4/Mandy 9.2/RedHat 9.0/Solaris/HPUX
Posts: 21

Rep: Reputation: 15
Cool

ok here is I would do the backup using tar with bz2 compression
use a dds-3 tape (12gb/24Gb capacity)

tar -cjvjpf /dev/st0 / /boot /etc /home /var /www


the way to recover from tape the entire system would be:

tar xvjpf /dev/st0

lyx0m
 
Old 10-30-2003, 01:50 PM   #5
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Original Poster
Rep: Reputation: 15
thank you.. I am testing the tar backup on one of my test systems. Until I get more familier with Linux I think I will stay with tar..
 
Old 11-28-2003, 04:32 PM   #6
troyboy
LQ Newbie
 
Registered: Nov 2003
Location: Missouri
Distribution: Redhat 9
Posts: 8

Rep: Reputation: 0
keeping permissions

Quote:
Originally posted by lyx0m
Hi
The way to backuop anytthing keeping the permisions woulld be:

tar cvpf /dev/st0 <whate_ever_path>, now, if you plan to backup on a daily basis y would suggest to put via cron:
00 23 * * * tar cvpf /dev/st0 /etc/httpd /var/www
this will allow you to backup automatically at 11pm everyday.

If you want to backup an entire system, I wond use another disk ass mirror and would type

dd if=<disk_device> bs=1024 of=<your_mirror_disk_device>

or you can send it to tape:

tar cvpf /dev/st0 / /etc /usr /var /tmp /opt /sbin (it depends how did you create your partitions and how big they are)
lyx0m
Hi Pengy,

I see that you use tar cvpf

Is it the p attribute that preserves the permissions?

This is an excerpt from the tar man page

Quote:
p Restore the named files to their original modes, and ACLs if applicable, ignoring the present umask(1) . This is the default behavior if invoked as super-user with the x function letter specified. If super-user, SETUID and sticky information are also extracted, and files are restored with their original owners and permissions, rather than owned by root. When this function modifier is used with the c function, ACLs are created in the tarfile along with other information. Errors will occur when a tarfile with ACLs is extracted by previous versions of tar .
Also, I am testing a backup script that I've written and I've included some exclude attributes in the tar.

example:

tar -czvfp /hd1.tar * --exclude-from backup-x

In the same directory that my backup script is located, I placed another file called backup-x which contains a list of files and directories that should be excluded from the backup process. I placed all of my large application installation files into a folder called apps and excluded the contents because I do not want to back up those large files every night when they do not change from day to day.

I also found that my script ran into a file called libnss_ldap-2.3.1.so that stopped the script and had an overrun loop that required me to hard reboot my server. That was before I used the 'p' attribute so it might have been a permissions issue (not allowing tar to copy the ldap file and edit permissions for security reasons probably).

I excluded the libnss_ldap-2.3.1.so file in the backup-x file. Do you think that will be a fatal mistake if and when have to do a restore?

Other exclusions included the name of the .tar files resulting from the backup, otherwise you end up backing up your backups, which is a major waste of space and might result in a never-ending loop.

One other thing...I forgot to use the standard suffix for my tar file which should have been .tgz since I was tarring and gzipping within one command. For a quick summary on tar and gzip see Redhat.com compression

What is st0 that you use in your example?
I see it in the /dev/ where there are 128 st# items stored. If I try to open it in pick or vi, it says it is not a file. Is this kernel base or something?
 
Old 11-28-2003, 08:40 PM   #7
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Rep: Reputation: 30
I boot a knoppix cd and run Partimage. I can image a 15gb partition to my 2nd hard drive easily. If I am only using 6gb's of that 15, the partition image will reflect that instead of needing 15gb's for the image. I do it with tar.gz, so the image is even smaller, say; 4gb's. There is ways to run Partimage with a script, but the partition you want to image can't be mounted. If you dual-boot different distro's you could do it from one, or it can even be done over a network if you have another machine.

Last edited by Scruff; 11-28-2003 at 08:44 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup and Restore with TAR jay2809 Linux - Newbie 7 08-25-2004 04:47 PM
tar to restore backup -- goes to sleep?!? JZL240I-U Linux - Software 4 05-10-2004 02:55 AM
Backup & Restore plan using tar markcasazza Linux - Newbie 1 04-14-2004 01:11 PM
tar backup & restore of current directory wishbone42 Linux - General 3 02-09-2004 02:30 AM
how can I restore a tar backup len snelly Linux - Newbie 1 04-30-2002 12:29 PM


All times are GMT -5. The time now is 09:45 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration