Last active
December 29, 2015 22:09
-
-
Save wouterds/7734948 to your computer and use it in GitHub Desktop.
VPS backup script to remote
This file contains 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/sh | |
## System Setup | |
## backup directory for temporary file storage | |
BACKUP=/backups | |
## FTP | |
FTP_DIR="/path/to/your/backup/folder/" | |
FTP_USER="your-ftp-username" | |
FTP_PASS="your-ftp-password" | |
FTP_HOST="ftp.yourhost.com" | |
FTP_PORT="21" | |
## Binaries | |
TAR="$(which tar)" | |
FTP="$(which ftp)" | |
## Today + hour in 24h format | |
NOW=$(date +%Y%m%d) | |
## To backup | |
DUMPFILE=$NOW.tar.bz2 | |
$TAR -cjf $BACKUP/$DUMPFILE /home /srv /etc /var /root | |
## ftp | |
cd $BACKUP | |
$FTP -in $FTP_HOST $FTP_PORT <<END_SCRIPT | |
quote USER $FTP_USER | |
quote PASS $FTP_PASS | |
cd $FTP_DIR | |
mput $DUMPFILE | |
bye | |
END_SCRIPT | |
## deleting temp files | |
rm -rf $DUMPFILE | |
echo "Backup finished and transferred" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Better way of backing up, but slower and more intensive.