LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-13-2006, 03:45 AM   #1
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Rep: Reputation: 32
FTP Script


Hi all

I've been working on a FTP script to upload some back up files onto another PC on my local network

So far so good, I get the email and the wall message and the backup file on the PC its meant to go too, but when I read my root mail I get the following message and I'm unsure what it means

Can any one let me know what it means please. Here is the email.

Quote:
mkdir: cannot create directory
`/folder/system/backup': File exists
tar: Removing leading '/' from member names
a folder
a folder/databases
a folder/html.bak
a folder/subs.bak
a folder/scripts
a folder/dbs_backup
a folder/system
a folder/system.txt
a folder/system/backup
a folder/system/backup/fullback.tar.gz: Can't add archive to itself
a folder/scripts/mysript1.sh
a folder/scripts/mysript2.sh
FTP script is here

Code:
#!/bin/bash

#Backup Script for Local Server Incremental Backups
#Broadcast Start of Backup - Uncomment Next Line
#wall A system backup is currently being performed...
mkdir /folder/system/backup
cd /folder/system/backup
#Tar files for this backup (I changed this to include tar and gz in one line.
tar -zcvf fullback.tar.gz /folder
#Mail the Administrator
#The system.txt file is what will be appended to your email. I put an
#announcement paragraph about the backup being complete.
mail username@myhost.com.au -s "FTP Backup Done" -v < /folder/system.txt
#Copy the tar file to the backup directory on the local host
#I removed the cp/rm commands here. 
#FTP the file to the backup directory on the backup server
ftp -in <<EOF
open xxx.xxx.x.x
user username password
bin
hash
prompt
dele fullback.tar.gz
put fullback.tar.gz
bye
EOF
wall The current backup was FTP'ed to the backup server. Please check status...
A system backup has completed... Files FTP'ed to Backup Server
TT
 
Old 07-13-2006, 03:56 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
mkdir /folder/system/backup
You are trying to create everytime the script runs that directory
 
Old 07-13-2006, 03:59 AM   #3
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
So you reckon hash out that line ( command ) and see what happens

thanks for the quick relpy bathory

TT
 
Old 07-13-2006, 05:15 AM   #4
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
I'm still getting this message in my root mail, and I have no clue what it means or how to fix, its got me stuffed, any one know please

Quote:
tar: Removing leading '/' from member name
TT

Last edited by tommytomato; 07-13-2006 at 05:17 AM.
 
Old 07-13-2006, 05:37 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
This is normal behavior of gnu tar. It means that when you'll extract the tarfile it will create the directory (folder in your case) under the current working dir and not at /. If you want to use the absolute path (i.e. extract the tarfile at /folder) use the "P" switch.
 
Old 07-13-2006, 05:52 AM   #6
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
Quote:
This is normal behavior of gnu tar. It means that when you'll extract the tarfile it will create the directory (folder in your case) under the current working dir and not at /. If you want to use the absolute path (i.e. extract the tarfile at /folder) use the "P" switch.
what do you mean by the "P" switch, bathory

TT
 
Old 07-13-2006, 06:19 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
From "man tar":
Quote:
-P, --absolute-paths
don't strip leading `/'s from file names
So if you use "tar czvfP fullback.tar.gz /folder", then using "tar zxvfP fullback.tar.gz" will extract the archive beginning from /. I think you should not use it since you can ovewrite something useful.


Quote:
mkdir /folder/system/backup
cd /folder/system/backup
#Tar files for this backup (I changed this to include tar and gz in one line.
tar -zcvf fullback.tar.gz /folder
Does this thing works? Because you create an archive of a directory (/folder) in a subdirectory (/folder/system/backup), so while you're tarring and file backup.tar.gz keeps changing!!!
 
Old 07-13-2006, 06:30 AM   #8
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
I took out this command all together since it was allready created once.
mkdir /folder/system/backup

the script does work, I get the wall message and the email and it uploads the file to another PC on my network ok, but I get a fcron error via root mail every hour which is tar: Removing leading '/' from member name

I'm kind of lost on what it all realy means, I spose thats why I came here to ask questions.

besides all that it was the only FTP script I could find.

TT
 
Old 07-13-2006, 07:00 AM   #9
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
Code:
 folder/system/backup/fullback.tar.gz: Can't add archive to itself
when it says that is it because it cant copy it self

TT
 
Old 07-13-2006, 07:12 AM   #10
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
top stuff

I fixed this error,
folder/system/backup/fullback.tar.gz: Can't add archive to itself

I created the folder out side that folder directory

just need to work out the other now "P" switch

TT
 
Old 07-13-2006, 07:51 AM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Use
Code:
tar czvfP fullback.tar.gz /folder
to create the archive so you will get rid of the warning. But don't use "P" if you're going to extract it, since it can ovewrite things.
 
Old 07-13-2006, 08:04 AM   #12
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
Quote:
to create the archive so you will get rid of the warning. But don't use "P" if you're going to extract it, since it can ovewrite things.
what you mean extract, do you mean unpack it

I would only unpack it if I needed some file to back up, say a database goes down, I would get the copy from the fullback.tar.gz file then import SQL, if you get what I'm trying to say.

TT
 
Old 07-13-2006, 08:14 AM   #13
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
It didn't like the P switch, file size was the same but the icon was different, if you get what I mean, I spose extracting it would of been acroupt file.

TT
 
Old 07-13-2006, 08:18 AM   #14
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
what you mean extract, do you mean unpack it
Yes
Quote:
I would only unpack it if I needed some file to back up
That's why I suggest you to not use the "P" switch if you're going to unpack it because if you unpack the whole archive to get 1 faulty file you'll ovewrite the rest.
 
Old 07-13-2006, 08:24 AM   #15
tommytomato
Member
 
Registered: Nov 2003
Location: Narrogin Western Australia
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964

Original Poster
Rep: Reputation: 32
thanks for your help bathory

It makes sence not to use the P option.

Only got one error now, just wondering if I rename the folders to a folder/html.bak/
folder/subs.bak/

as in creating a folder, if you get what I mean

TT
 
  


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
FTP script the_imax General 6 12-30-2005 01:27 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
Ftp script scialom Linux - Software 2 05-04-2004 03:03 PM
FTP script Veteq Programming 3 04-21-2004 12:32 PM
ftp script dlm4444 Linux - Networking 5 02-10-2004 11:41 PM

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

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