View Full Version : Tar Backup of Webserver on FC10
newhelpeeps
27th January 2009, 04:14 PM
I want to backup my apache website using tar. I want to make sure all the permissions and such stay the same so that if I restore a website, it's ready to go exactly as it had been.
I am using the following command and would like to know if there is anything else I should neeed to do?
tar --xattrs cvzf backup.tgz /path-to-webserver-files
Now my other question is since tar doesn't store absolute paths, when I run the restore I have to be in the root directory? In another words if I run the command in a user directory will tar do something retarded like encode the paths as ../path-to-webserver or will it just be path-to-webserver so that when I run the restore from the / folder it will automatically go into the right place?
Thanks!
neogranas
27th January 2009, 04:43 PM
I'd recommend going to the directory that contains the folder(s) for the files you want. As an example, my websites are in /home/user/public_html/
So I change to /home/user/ then run the tar command on public_html so that it grabs all my websites, then to restore it I just go to the /home/user/ folder and unpack it. The basic idea I'm trying to get to is whatever directory you start your tar in, make sure you can untar in the same folder.
newhelpeeps
27th January 2009, 08:09 PM
OK so I figured out the tar storage format, no matter what dir I create the archive in it just removed the first "/" so like if I do a tar file of "/var/log" it saves as "var/log" which is very good. Now my question is I am backing up all of the attributes and crap. I made a script that saves my config files and data. I think I can just reinstall fedora and untar in the root dir to fix. See any issues I need to be aware of? Here's the script I manually will run every now and again
#!/bin/bash
tar --xattrs -cpvzf backup.tgz /var/www/html
tar --xattrs -cpvzf backupconfig.tgz /etc
mysqldump -u root -p --all-databases > mysql.sql
stevea
28th January 2009, 05:17 AM
You don't need to cd to the directory, just use the "-C dir" option. This also works on extract.
If you ever want the leading "/" then use the "-P" option.
Yes the --xattrs captures selinux context and acls (if these exist) and -p implies the basic perms.
Just a thought ... you may want to consider a differnet compression
tar --use-compress-program=lzop --xattrs -cpvzf backup.tar.lzo /var/www/html
lzop is not quite as good at compression as gzip, but is much faster.
newhelpeeps
28th January 2009, 08:01 AM
Good to know, have to say gzip did compress 130megs down to 16! I think it was mostly text data and pictures it didnt make much of a difference on... not sure I'd want it trying to do much with my pictures anyway!
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.