Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964
Rep:
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
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.
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964
Original Poster
Rep:
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.
-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!!!
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964
Original Poster
Rep:
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.
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964
Original Poster
Rep:
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.
Distribution: GUI Ubuntu 14.0.4 - Server Ubuntu 14.04.5 LTS
Posts: 964
Original Poster
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.