Deploy via FTP

My web hosting is a low-cost one and doesn’t provide a SSH access. I can’t use Octopress’ deployment methods, only FTP.

Tired of drag-and-dropping my files in FileZilla, I decided to use lftp and to configure the Rakefile accordingly.

In Rakefile, add:

1
2
3
4
5
6
## -- LFTP Deploy config -- ##
ftp_user = "login"
ftp_password = "password"
ftp_server = "server"
ftp_target = "/remote/path/to/blog"
deploy_default = "lftp"

and:

1
2
3
4
5
desc "Deploy website via LFTP"
task :lftp do
puts "## Deploying website via LFTP"
ok_failed system("lftp -e 'mirror -R --ignore-time --delete -v #{public_dir} #{ftp_target}; bye' -u #{ftp_user},#{ftp_password} #{ftp_server}")
end

Now, I can rake deploy!

Note: if you don’t want to put your password in the Rakefile, use:

1
2
3
4
5
desc "Deploy website via LFTP"
task :lftp do
puts "## Deploying website via LFTP"
ok_failed system("lftp -e 'mirror -R --ignore-time --delete -v #{public_dir} #{ftp_target}; bye' -u #{ftp_user} #{ftp_server}")
end

and lftp will nicely ask for your password.

Note 2: I updated the lftp command to add the --ignore-time option. It only uploads files with a different size even if Octopress regenerates everything.

Note 3: I updated the lftp command to add the --delete option. It deletes files that no longer exist in the public/ directory. Thank you Justin Gordon for the suggestion.