Today most of of people use control panel like cPanel, Plesk, DirectAdmin, Webmin, ISPConfig etc for linux server management. But there are still many people who prefer and use plain lamp server. As they have been using it for years and find it much easier. The control panels provide automated remote ftp backup feature and it automatically upload multiple files to remote ftp backup server. Now within plain linux servers it’s a real pain writing custom script for creating backups and uploading the files.
Now a lazy linux system administrator like me will always find an simple and easy way to do this instead of writing the complex scripts. Now with a little research I was able to find command line program call Lftp. FTP is a sophisticated ftp/http client, and a file transfer program supporting a number of network protocols. Like BASH, it has job control and uses the readline library for input. It has bookmarks, a built-in mirror command, and can transfer several files in parallel. It was designed with reliability in mind. LFTP is free software, distributed under the GNU GPL license.
Below are the lftp commands for uploading and downloading files and folders recursively.
Recursive File Upload
lftp -e 'mirror -R /local/directory/path/ /remote/backup/directory' -u user,password ftp.your-remote-backup-server.com
The -R switch means “reverse mirror” which means “put” [upload].
Recursive File Download
lftp -e 'mirror /remote/backup/directory /local/directory/path/ ' -u user,password ftp.your-remote-backup-server.com