LinuxQuestions.org
Help answer threads with 0 replies.
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 08-18-2006, 04:58 AM   #1
eswanepoel
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Rep: Reputation: 0
Backup script not workin as intended


HI
I have red hat 9 and use it as a Apps server. I discover that my monthly backup is not backing up everything in the director as I thought. This is the part that is not working properly, there is no errors that is points out anything so I think my script is not write


This is the script:
cd /usr/local/backup/divacc
# rm *
cp -p /usr/local/appxdata/DIV/ACC/Data/*.* /usr/local/backup/divacc
pwd
ls -al |more
 
Old 08-18-2006, 06:29 AM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
Code:
cd /usr/local/backup/divacc
# rm *
cp -p /usr/local/appxdata/DIV/ACC/Data/*.* /usr/local/backup/divacc
pwd
ls -al |more
This is your problem right here. *.* is DOS related. It won't work as expected in Unix. It will only grab files which contain a "." and not all files. Also, your current command won't grab directories below this either.

Here is what I would recommend as a base.
Code:
# rm /usr/local/backup/divacc/*
cd /usr/local/backup/divacc
tar cf - /usr/local/appxdata/DIV/ACC/Data | tar xpf -
pwd
ls -al |more
This uses tar... and will be a little better. I suggest forgetting the "rm" part of this code (in the rare case that your script fails you'll have nothing at all backed up). Also, everything after the tar command isn't really needed either (if you want stats use "xpvf" instead of "xpf" in the second tar command.

And finally... you really should be backing this up to another disk, another computer, and/or another location. If your disk went you would lose everything here.

Note: this is a base. Some things are still goofy here but it's early and I'm on my way to work. What you need to do is actually start the tar command in the first directory and pass a flag to the second tar command about where to unpack it. So you won't recreate the whole directory structure in the file.

Edit: Also, you could fix your copy command to make it work correctly in this instance. But it is wise to have a backup plan in place which is expandable in case you need it. The "cp" method is easy to put in place when you have a very simple structure and plan. But it won't grow with the system well.

Last edited by frob23; 08-18-2006 at 06:37 AM.
 
Old 08-18-2006, 09:07 AM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,765

Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
# rm /usr/local/backup/divacc/*
cd /usr/local/backup/divacc
tar cf - /usr/local/appxdata/DIV/ACC/Data | tar xpf -
pwd
ls -al |more

should be amended as follows:

tar cf - /usr/local/appxdata/DIV/ACC/Data | (cd /usr/local/backup/divacc; tar xpf -)
 
Old 08-18-2006, 07:19 PM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
Quote:
Originally Posted by bigrigdriver
# rm /usr/local/backup/divacc/*
cd /usr/local/backup/divacc
tar cf - /usr/local/appxdata/DIV/ACC/Data | tar xpf -
pwd
ls -al |more

should be amended as follows:

tar cf - /usr/local/appxdata/DIV/ACC/Data | (cd /usr/local/backup/divacc; tar xpf -)
There you go. I knew I was missing that this morning but I was literally out the door. Thanks.
 
  


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
Need backup script. gtrawoger Linux - Software 2 07-17-2006 07:31 AM
This was intended to be the first one ;-) gtc1977 LinuxQuestions.org Member Intro 2 03-17-2006 04:07 PM
alias not workin inside a script sanjith11 Programming 7 08-31-2005 03:36 PM
Script Backup Buto Linux - General 2 10-18-2004 05:56 PM
Backup Script imsajjadali Linux - General 7 01-28-2004 03:30 PM


All times are GMT -5. The time now is 02:43 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