Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Doulos
Life Cycles Becoming CPU Cycles



Joined: Jun 06, 2005
Posts: 732

PostPosted: Fri Jan 28, 2011 1:00 am Reply with quote

I really don't know what I am doing so I am looking for some help...

Goal: backup /public_html but exclude directory A , gzip it and move it from the root directory to directory B.

( have very many, very large sermons in mp3 format in directory A which I don't want backed up as I already have them locally.)

Attempted:
Code:
date=`date -I` ; tar -zcf backup_$date.tgz ./public_html --exclude=/home/username/public_html/directory A > /home/username/directory B/backup_$date.tgz    


Result: makes a bu and puts it in the root dir, but does not exclude dir A. Also puts a bu file with the same name in dir B, but it is empty. I don't know for sure that dir A is not being backed up, but the bu file is huge (+800MB) and this site is just a joomla site with a lot of media files in dir A - it would not be so big if it was excluding dir a. I think the job is timing out before it completes since attempts to unpack the tgz file halts before done saying it is broken. , but a test on another account w/o large files showed the "excluded" folder is indeed being backed up.

If someone could explain what I am doing wrong I would appreciate it.

Thanks
 
View user's profile Send private message
Doulos







PostPosted: Fri Jan 28, 2011 11:59 am Reply with quote

Ok, I don't really need to move it to another dir so here is what I tried last but it still doesn't work:
Quote:
date=`date -I` ; tar -zcf backup_$date.tgz --exclude= "/home/crcheek/public_html/components/com_sermonspeaker/media" ./public_html
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Jan 29, 2011 9:08 pm Reply with quote

I would fully qualify where you want the tar file to be created. Glad you got rid of the redirect of standard out.. Wink I would think this should work.

Code:


date=`date -I` ; tar -zcf <<path to directory B>>/backup_$date.tgz ./public_html --exclude=/home/crcheek/public_html/components/com_sermonspeaker/media


If not, try changing your --exclude to:

Code:


--exclude=./public_html/components/com_sermonspeaker/media


Also, the way I do this on Linux is the following (slightly modded - I put the script in my /etc/cron.weekly so that I get a weekly backup).

Code:



#!/bin/bash
#!/bin
###
# Ubuntu Weekly Backup Script:  Full Backup Run Weekly
#
# @category    Utility
# @package     Admin
# @subpackage  Backup
# @author      Rob Herder (aka: montego) <montego@montegoscripts.com>
# @copyright   2009-2010 by Montego Scripts
# @license     http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt GNU/GPL 2
# @version     1.1.0
# @link        http://montegoscripts.com
# @comments    This script is submitted via crontab with the root user weekly.
#              See root user crontab for run schedule.  NOTE: was moved to
#              /etc/cron.weekly (at the end).
# @changelog   1.1.0 - Added change of permissions on backup files at end so home user can read.
# @changelog   1.2.0 - Added exclusions and separate backup of VirtualBox Machines.
# @changelog   1.3.0 - Added test of target path to make sure its available; if not, ____
# @changelog   1.4.0 - Directory for VMs changed with 10.10/4.0
###
#
# Misc defines
#
buDir="/media/backups/HOME07u"
#
# Excludes
#
ex01="--exclude=tar_system_backup_*.tgz"
ex02="--exclude=tar_home_backup_*.tgz"
ex03="--exclude=tar_config_backup_*.tgz"
ex04="--exclude=/home"
ex05="--exclude=/media/*"
ex06="--exclude=/mnt/*"
ex07="--exclude=/proc/*"
ex08="--exclude=/sys/*"
ex09="--exclude=lost+found/*"
ex10="--exclude=.Trash/*"
ex11="--exclude=/boot/grub/menu.lst"
ex12="--exclude=/boot/grub/device.map"
ex13="--exclude=/etc/fstab"
ex14="--exclude=/etc/mtab"
ex15="--exclude=/etc/X11/xorg.conf"
ex16="--exclude=/home/********/.thumbnails/fail/gnome-thumbnail-factory/*"
ex17="--exclude=/home/********/.thumbnails/normal/*"
ex18="--exclude=windows_backup_*.img"
ex19="--exclude=/home/********/VirtualBox VMs"
#
# Includes
#
inc1="/boot/grub/menu.lst"
inc2="/boot/grub/device.map"
inc3="/etc/fstab"
inc4="/etc/mtab"
inc5="/etc/X11/xorg.conf"
inc6="/home/********/VirtualBox VMs"
#
# Backup files
#
file1="tar_config_backup_`date +%Y.%m.%d`.tgz"
file2="tar_system_backup_`date +%Y.%m.%d`.tgz"
file3="tar_home_backup_`date +%Y.%m.%d`.tgz"
file4="tar_VirtualBox_backup_`date +%Y.%m.%d`.tgz"
#
# Perform the backup
#
if cd $buDir
then
   tar cvpzf $file1 $inc1 $inc2 $inc3 $inc4 $inc5
   tar cvpzf $file2 $ex01 $ex02 $ex03 $ex04 $ex05 $ex06 $ex07 $ex08 $ex09 $ex10 $ex11 $ex12 $ex13 $ex14 $ex15 /
   tar cvpzf $file3 $ex01 $ex02 $ex03 $ex09 $ex10 $ex16 $ex17 $ex18 "$ex19" /home
   tar cvpzf $file4 "$inc6"
   chown *********:******* $file1 $file2 $file3 $file4
else
    echo "Weekly backup script failed due to wrong backup directory"
    exit 1
fi


Feel free to "steal shamelessly" if it helps you. Yes, I blanked out just a few things with "********", but you get the point.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Doulos







PostPosted: Sat Jan 29, 2011 11:38 pm Reply with quote

Thanks, Montego. I will try to get to that asap, but I am worn out. Just married off my last daughter today.
 
montego







PostPosted: Tue Feb 01, 2011 8:41 pm Reply with quote

Oh my. Sad That is not only a tiring process, but a sad day to boot I'm sure. However, knowing you, you've "trained her up in the way she should go"... Wink Congratulations as well as my sympathies my friend.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©