It is good to have automatic backups of critical servers. An easy way to make these backups is with a utility called rsync, but if you have to back up to a server that only supports FTP, here's a different approach.
Some commands may require root permission, so log in as a standard user and use sudo. |
Install lftp
yum install lftp |
Create the backup script
Create the new file
You can save the file anywhere you like, it doesn't have to be in the example location we are using here. |
nano /home/admin/Documents/backup.sh |
Insert the script contents into the file
#!/bin/bash # Backs up files to remote FTP server HOST='server.example.com' USER='username' PASS='password' TARGETFOLDER='/target' SOURCEFOLDER='/source' lftp -f " open $HOST user $USER $PASS lcd $SOURCEFOLDER mirror --reverse --delete --verbose $SOURCEFOLDER $TARGETFOLDER bye " |
Make the file executable
chmod +x /home/admin/Documents/backup.sh |
Add the file to cron to make it execute automatically on a schedule.
The example below will execute every day at 2:00 AM. |
0 2 * * * /home/admin/Documents/backup.sh |
You can run the script manually to verify that it works.
sh /home/admin/Documents/backup.sh |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|