January 23, 2015
What is lftp?
Why do I want to use it?
Installation on CentOS 5
Installation on Ubuntu
sudo apt-get install lftp
Mirroring from local directory to remote ftp from command line
To mirror from a local directory to a remote ftp account you would want to run the following:
, -e "mirror --reverse --delete --only-newer "
Where you replace the following variables:
|<local dir>||Directory where your files are
|<remote dir>||The remote directory to upload to
|<ftp server>||The FTP Server you are connecting to
You should see a status screen that shows you the uploads. Try running it again, you will see nothing is transfered because they are already there!
Mirroring from local directory to remote ftp from a script
Great, now everything is working correctly, however doing it from command line has a few drawbacks. First, you have to type it in everytime, this can be a pain. Second, your username and password would be saved in your history.
- To fix these drawbacks we will want to create a script that has all of the variables in it.
- Edit a file, lets call it lftpcommand.txt (you can all it whatever you want).
- In it place the following:
user mirror --reverse --delete --only-newer
Now to run the command we will use:
lftp -f lftpcommand.txt