Help with backup shell script

Hello,

Need help with a script to backup a configuration file
BSD
Save the file / Firewall / ConfigFiles to a remote ftp server

here is the script

 # / bin / sh
 Date = $ (date +% d-% Y-% m-H-M)

 tar-cvf ConfigFiles.tar / Firewall / ConfigFiles
 ConfigFiles.tar mv / Firewall-$ {DATE}. tar
 ftp-in
 Open 192.168.X.X
 user XXX

 could *. tar
 close

Thank you for your help

Hi,
I think you need to read man page about ftpput (but I don't know, if ftpput is in BSD).

Grr, I am not able to post links in the post :slight_smile: so.. google ftpput :slight_smile:

I confirm that I could use ftp put on bsd
I already made the transfer without using script shell

So, what you need now? :slight_smile:

my script does not work

Ah.. ok, I will send you some example :slight_smile:

And change that ftpput line :slight_smile:

btw. I changed your date to 16-04-2011--14-59 :slight_smile:

#!/bin/sh

date=$(date +%d-%m-%Y--%H-%M)

tar -cvf ConfigFiles.tar /Firewall /ConfigFiles
ftpput --server=192.168.X.X --user=XXX --pass=YYY ConfigFiles.tar
SUCCESS=$?

if [ "$SUCCESS" -eq 0 ]; then
   echo "Everything is OK."
else
   echo "ERROR!"
fi

// edited: I add test if transfer was ok :slight_smile:

thank you I'm trying this now and I tell you if it works:)

---------- Post updated at 08:33 AM ---------- Previous update was at 08:04 AM ----------

sorry it doesn't work
i change my script to this

-----------------------------

#!/bin/sh
Date=$(date +%d-%m-Y-%H-M)

tar -cvf ConfigFiles.tar /Firewall/ConfigFiles
mv ConfigFiles.tar /backup/ConfigFiles-${DATE}.tar
ftp -in <<THEEND
open 192.168.0.11
user xxx xxxx

cd backup
put *.tar
close

------------------------------------
and i have this message in sceen

mv: rename ConfigFiles.tar to /backup/ConfigFiles-.tar: No such file or directory
ftp: connect: Operation timed out
Not connected.
Not connected.

And /backup folder exists? :slight_smile:

ls -lad /backup

the backup folder existe only in my ftp server
i add the backup Folder and i have the same Message

thank you for your help
I look at this issue another day if it works I'm sending a message

oh, because in your script you have

mv ConfigFiles.tar /backup/ConfigFiles-${DATE}.tar

For me (on Debian) works this solution:

ftp -in <<EOF
open 192.168.0.11
user xxx xxxx
cd backup
put *.tar
close
EOF

It works problem at my filtering firewall that does not put command
I allowed that and it works
thank you

have nice dayhenriette

hi telouet ,

the problem my be the DATE variable initialization is wrong as you use Date variable but in mv command you use $DATE so try the below :

#!/bin/sh
DATE=$(date +'%d-%m-%Y-%H-%M')

tar -cvf /tmp/ConfigFiles.tar /Firewall/ConfigFiles

mv /tmp/ConfigFiles.tar /backup/ConfigFiles-${DATE}.tar

ftp -in <<THEEND
open 192.168.0.11
user xxx xxxx

lcd backup #the remote dir you want to ftp file to 
cd /backup/ # the local dir which have the file
lls 
ls  

put ConfigFiles*.tar

bye

THEEND


1 Like