Wednesday, May 4, 2011

How to backup files to a FTP server using cURL

To easily backup files to your local FTP server directly from your bash shell, you have one simple option which requires not much work: just use cURL.

cURL, which you can find here, is a command line tool for transferring data using FTP, FTPS, HTTP, HTTPS, TELNET, TFTP and many more protocols.

# Configuration section
HOST="my_ip_address"
USER="username"
PASS="password"
PATH_REMOTE="/folder/distant"
FILENAME="/folder/local/filename"

# Data transfer
curl -T $FILENAME -u $USER:$PASS $HOST/$PATH_REMOTE

This script can be useful to backup data to another server, if used together with another gzip command that takes care of preparing the tar archive to send. Once you have run gzip, just cURL the newly created gzipped tar file up to a different server running FTP.

Nothing better than a simple solution.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...