Skip to content

Instantly share code, notes, and snippets.

@ianthekid
Last active March 4, 2019 06:12
Show Gist options
  • Save ianthekid/4e6a43a656a90dd05a098796bf24084c to your computer and use it in GitHub Desktop.
Save ianthekid/4e6a43a656a90dd05a098796bf24084c to your computer and use it in GitHub Desktop.
#!/bin/sh
# BACKUP SCRIPT
# DATABASE
DBNAME="dbname"
DBUSER="dbuser"
DBPASS="dbpass"
# PATHS
DIRDB="/backup/db"
DIRBACKUP="/backup"
DIRFILES="/var/www/html"
# BACKUP DB AND FILES
mysqldump -u "$DBUSER" --password='"$DBPASS"' "$DBNAME" > "$DIRDB"/`date +%Y-%m-%d_%H-%M`.sql
tar --exclude=**/.git/* --exclude=**/node_modules/* -cf "$DIRBACKUP"/`date +%Y-%m-%d_%H-%M`.tar.gz -z -C "$DIRFILES" .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment