LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-11-2006, 10:17 PM   #1
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 963

Rep: Reputation: 32
Backing up Folders


Hi all

I'm trying to work out how to back up certain folders with in my Linux box.

just wondering if this looks right ??? how ever I would like it to back up the tar file into another folder called ( lets say ) /Downloads/html.bak

my bin bash

Code:
!/bin/bash 

# this file is my automated backup script, htmlbackup.sh. 

cd /srv/www/html/ 
rm htmlbackup.sh.tar.gz 
tar -zcf htmlbackup.sh.tar.gz .
my cron should be some thing like this

Code:
34 9 * * * /srv/www/backup.sh
system is Tinysofa Ceara

Do I add the following , sorry alittle lost

Code:
rm /Downloads/html.bak/htmlbackup.sh.tar.gz
tar -zcf /Downloads/html.bak/htmlbackup.sh.tar.gz .
TT

Last edited by tommytomato; 07-11-2006 at 10:18 PM.
 
Old 07-12-2006, 12:52 PM   #2
r£vilo
LQ Newbie
 
Registered: Jun 2006
Distribution: freebsd 6.1, suse 10.1, Centos 4.3, PCLOS Super Gamer
Posts: 28

Rep: Reputation: 15
i would do:
Code:
!/bin/bash 

# this file is my automated backup script, htmlbackup.sh. 

cd /srv/www/html/ 
rm htmlbackup.sh.tar.gz 
tar -zcf htmlbackup.sh.tar.gz .
cp /srv/www/html/htmlbackup.sh.tar.gz /Downloads/html.bak/htmlbackup.sh.tar.gz
or i wud do
Code:
cd /srv/www/html/
tar -zcf htmlbackup.sh.tar.gz
rm /Downloads/html.bak/htmlbackup.sh.tar.gz
mv /srv/www/html/htmlbackup.sh.tar.gz /Downloads/html.bak/
No you do not need to add the extra code.
btw u do not really need the rm command as cp will automatically overwrite it.

What are you lost on?
 
Old 07-12-2006, 09:41 PM   #3
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 963

Original Poster
Rep: Reputation: 32
So I can take out the rm command

I'm getting the following email in root mail. if you get what I mean

Code:
/folder/folder/htmlbackup.sh: line 1: !/bin/bash: No such file or directory
rm: cannot remove `/folder/folder/htmlbackup.sh.tar.gz': No such file or directory
with your top script wouldn't it be better if the tar was before the rm like so, or have I got it wrong.

Quote:
#!/bin/bash

# this file is my automated backup script, htmlbackup.sh.

cd /srv/www/html/
tar -zcf htmlbackup.sh.tar.gz .
rm htmlbackup.sh.tar.gz
cp /srv/www/html/htmlbackup.sh.tar.gz /Downloads/html.bak/htmlbackup.sh.tar.gz
TT

Last edited by tommytomato; 07-12-2006 at 09:43 PM.
 
Old 07-13-2006, 11:56 AM   #4
r£vilo
LQ Newbie
 
Registered: Jun 2006
Distribution: freebsd 6.1, suse 10.1, Centos 4.3, PCLOS Super Gamer
Posts: 28

Rep: Reputation: 15
Quote:
So I can take out the rm command
Whoops, i misread the code: i thought you were deleting the file /Downloads/html.bak/htmlbackup.sh.tar.gz rather than the file /srv/www/html/htmlbackup.sh.tar.gz. Sorry! So no you do not remove the rm command.
Quote:
with your top script wouldn't it be better if the tar was before the rm like so, or have I got it wrong.
No it wont archive if you do not delete it first even if it did your whole script would be pointless because it would backup the file then delete it right afterwards (so you have no backup). If you have the rm command first it will delete the file when you are backing up. Or if by that you mean you do not want the file htmlbackup.sh.tar.gz in /srv/www/html then add the rm command after te line cp /srv/www/html/htmlbackup.sh.tar.gz /Downloads/html.bak/htmlbackup.sh.tar.gz
Quote:
I'm getting the following email in root mail. if you get what I mean
Code:
/folder/folder/htmlbackup.sh: line 1: !/bin/bash: No such file or directory rm: cannot remove `/folder/folder/htmlbackup.sh.tar.gz': No such file or directory
To stop getting that there is a simple solution which is just to create the file /folder/folder/htmlbackup.sh.tar.gz Then after that as there is a file to delete so you wont get an error and the script can run the whole way through (as the error stops it before it creates the file htmlbackup.sh.tar.gz).

Hope that helps.
 
Old 07-13-2006, 08:08 PM   #5
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 963

Original Poster
Rep: Reputation: 32
cheers for that r£vilo

the only error I have now

TT

Last edited by tommytomato; 07-13-2006 at 08:52 PM.
 
Old 07-14-2006, 09:34 AM   #6
r£vilo
LQ Newbie
 
Registered: Jun 2006
Distribution: freebsd 6.1, suse 10.1, Centos 4.3, PCLOS Super Gamer
Posts: 28

Rep: Reputation: 15
what is the error?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
symlinks from folders to folders? vbsaltydog Linux - Newbie 4 04-03-2006 01:51 PM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM
Backing Up RH 6.1 Lilbudha Red Hat 1 05-20-2005 06:12 AM
backing up coheed Linux - Software 4 01-25-2004 09:01 PM
Backing up Cichlid Linux - General 1 12-16-2002 10:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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