Forked from viras34/gist:1eed4c8acb2d8996cb5af376644e021f
Created
February 26, 2024 01:33
-
-
Save 1gor/338874213ede621b1b5e0203d41bb0a6 to your computer and use it in GitHub Desktop.
Automated backups to FTP server using rsync and curlftpfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using curlftpfs and FUSE, a ftp site is mapped to the local file system and rsync will backup files to the ftp server automatically. | |
1. Install required packages | |
apt-get install curlftpfs rsync | |
2. Create directory to mount the ftp site | |
mkdir /mnt/ftpbackup | |
3. Add the curlftpfs mount into fstab to make it mount everytime the system is started (pico /etc/fstab) | |
curlftpfs#{username}:{password}@{host} /mnt/ftpbackup fuse rw,allow_other,uid={userid} 0 0 | |
{username} = FTP username | |
{password} = FTP password | |
{host} = FTP host/ip | |
{userid} = ID of a local user (ex. 1001) | |
4. Mount the ftp site | |
mount /mnt/ftpbackup | |
5. Backup using rsync | |
rsync -avz --no-owner --no-group /var/www /mnt/ftpbackup | |
All files in the /var/www folder will be synced to the remote machine into a folder named backup | |
6. Automate the backup using cron (crontab -e) | |
0 3 * * * rsync -az --no-owner --no-group /var/www /mnt/ftpbackup >> /dev/null 2>&1 | |
Your /var/www will be synced to the remote machine at 3am every day |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment