ftp script to make a backup?

General support questions including new installations
Post Reply
centos9
Posts: 15
Joined: 2009/09/21 13:23:57

ftp script to make a backup?

Post by centos9 » 2011/07/09 16:13:01

Hello,

I am trying to create a script which will backup all my data to a remote ftp server

I need to tar all folders inside /data separately /data/as - /data/as/001 - /data/as/002 - /data/as/003 /data/as/004 - etc etc

[code]for dir in */; do dir=`echo $dir | tr -d '/'`; echo $dir; tar czf $dir.tar.gz $dir; done[/code]

the above code works fine but only if I run it from inside each directory - so how can I tar all folders inside the /data folder and put the tar files into a different folder with the original name of the folders?

ftp script

[code]

#!/bin/sh
USERNAME="your-ftp-user-name"
PASSWORD="your-ftp-password"
SERVER="your-ftp.server.com"

# local directory to pickup *.tar.gz file
FILE="/data/as"

# remote server directory to upload backup
BACKUPDIR="/backup"

# login to remote server
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
cd $BACKUPDIR
mput $FILE/*.tar.gz
quit
EOF

[/code]


the above ftp script doesnt work - it gives an error even though the file does exist after I run the first script
AUTH not understood KERBEROS_V4 rejected as an authentication type
/data/as/001.tar.gz: No such file or directory


I need to make this as a single script so I can run it in the background as a cron job


thanks

hansolo
Posts: 231
Joined: 2010/01/13 11:17:42
Location: SI

Re: ftp script to make a backup?

Post by hansolo » 2011/07/11 13:13:25

Hi,

maybe you should use "lftp" instead of 'ordinary' ftp
and get some script code from my FTP backup [url=http://centosforserver.blogspot.com/2010/02/backup-script-with-tar-incremental.html]script[/url]

good luck

thusithathik
Posts: 2
Joined: 2016/06/07 18:30:56

Re: ftp script to make a backup?

Post by thusithathik » 2016/10/04 07:05:54

when run sh file following error giving

''The system cannot find the file specified.''

Thanks,
Thusitha

Post Reply