Backups using LFTP
This guide explains how to perform backups from server_1 to server_2 using FTP. Here we are assuming that that server_2 has an FTP server running and server_1 is performing the backup.
- Make sure you have lftp installed.
- Create an FTP user on server_2 and give them a chroot’d home directory.
- Create a script file that lftp will use as a set of instructions:
/root/cron/lftp.script 1
2
3
4
5
6#!/bin/bash lftp -c "set ftp:listoptions -a; open ftp://username:password@hostname; lcd /path/to/local/directory/on/server_1; cd /path/on/ftp; mirror --reverse --delete --verbose
- Create a shell script to execute the backup:
/root/cron/backup.sh 1
2#!/bin/bash lftp -f /root/cron/lftp.script
- Add the command to crontab:
crontab -e 1
2
3# Executes at 3am 0 3 * * * nice 19 /root/cron/backup.sh >> /root/cron/logs/backup.log 2>&1