My office have ftp sever how can i set ftp client to back up some folder automatic every day
Who is Participating?
stefan73Connect With a Mentor Commented:
Hi teera,
Check "man .netrc" how to install some automatic FTP script.

You probably should use a two-stage cron script:

1. A script which creates the backup file

(like with:
find $HOME -type f -mtime -1 > ~/newfiles
tar -cf - --files-from ~/newfiles | bzip2 -9 > newfiles.tar.bz2
mv newfiles.tar.bz2 newfiles_ready.tar.bz2

Instead of $HOME you can use any other folder. bzip2 is very efficient, but also a bit slow. If speed is an issue, use gzip -1 instead.

2. An FTP script which simply uses "ftp backup", which will then use all the settings you defined in .netrc

-> This is still quite crude. There are better ways, such as using rsync via ssh. But you'll probably want a working solution first before refining it.

Karl Heinz KremerCommented:
You can also use wget to retrieve the files from the ftp server. wget should be part of any major Linux distributions.
da99rmdConnect With a Mentor Commented:
Here is a easy sript based on  stefans code:

tar -cf - (the name of the dir to backup) | bzip2 -9 > newfiles.tar.bz2 && mv newfiles.tar.bz2 newfiles_ready.tar.bz2 && ncftpput -u (username) -p (password) (remote-host) (remote-directory) newfiles_ready.tar.bz2
# End script

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Karl Heinz KremerCommented:
ncftpput is part of ncftp, which may not be installed automatically (or may not be part of your distribution at all).
ncftp but its part of most distributions, and then how do you use wget to put files ?

Karl Heinz KremerCommented:
You run wget from the machine that receives the files. If you need to put something on a ftp server, you need wput (which is a seperate project, and not part of most distributions).
>how do you use wget to put files ?

You could have the server "pull" them instead of the client "pushing" them. But you're right, this is probably less efficient.

The only reason to use this is security considerations. If the client is considered "unsafe", it's better to have the server get the file.
Karl Heinz KremerCommented:
The question did not say which directions the files need to be moved. I just assumed that something on the server needs to be backed up. But you are right, it could be the other way as well.
teera, plz give some more detailed information about what you mean.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.