Skip to content

Instantly share code, notes, and snippets.

@joduplessis
Created March 21, 2018 14:57
Show Gist options
  • Save joduplessis/2399164958a3f08e2c154cd7dcf31548 to your computer and use it in GitHub Desktop.
Save joduplessis/2399164958a3f08e2c154cd7dcf31548 to your computer and use it in GitHub Desktop.
Backup pipeline running every day for a Linux VPS. Zips folder & files and FTPs to a location.
#!/bin/bash
# Change the directory
cd /home/username/backup
# First do our MySQL dump
mysqldump -u root -p "PASSWORD" --all-databases > alldb.sql
# Copy all sorted of stuff here to the backup folder
cp -r /home/username/files /home/username/backup/files
# Zip up everything, encrypt & password protect
zip -P SECRET -r /home/username/backup/backup.zip *
# FTP it off site
lftp -u FTP_USERNAME,FTP_PASSWORD FTP_HOST -e "put -O public_html/backup/ /home/username/backup/backup.zip; bye"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment