Last active
June 16, 2021 07:36
-
-
Save matteomattei/cf0dabd87aa34fd4d10a to your computer and use it in GitHub Desktop.
A simple script to backup Plesk server and store data in a remote FTP
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
#!/bin/bash | |
set -e | |
FTP_USER="ftp_user" | |
FTP_PASS="ftp_password" | |
FTP_HOST="ftp_host" | |
# REMOVE BACKUPS OLDER THAN 7 DAYS | |
FILES=$(lftp -e 'cd pleskbackup; cls --sort="date"; exit;' -u ${FTP_USER},${FTP_PASS} ${FTP_HOST}) | |
if [ $(echo "${FILES}" | wc -l) -gt 7 ]; | |
then | |
FILE_TO_REMOVE=$(echo "${FILES}" | head -n1) | |
lftp -e "cd pleskbackup; rm -f ${FILE_TO_REMOVE}; exit;" -u ${FTP_USER},${FTP_PASS} ${FTP_HOST} | |
fi | |
/usr/local/psa/bin/pleskbackup server --skip-logs --output-file=ftp://${FTP_USER}:${FTP_PASS}@${FTP_HOST}/pleskbackup/`date +%F`_full_psa_backup.raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to manually install lftp:
apt install lftp for Debian/Ubuntu
yum install lftp for RedHat/CentOS