Author: thomasl

Simple database backup shellscript

I made a simple shellscript it will:

  • dump a few databases
  • create a tar.gz from them
  • scp a copy of the tar.gz to my backups folder on a remote server, this way I will always have a backup of my most important databases on a remote location.
#!/bin/sh

mysqldump db_name1 -u myUser -pMypassword > db_namedump1$(date +%F_%R).sql
mysqldump db_name1 -u myUser -pMypassword > db_namedump2$(date +%F_%R).sql
mysqldump db_name1 -u myUser -pMypassword > db_namedump3$(date +%F_%R).sql

FILENAME="compressed-$(date +%F_%R).tar.gz"
tar -czf ./backups/$FILENAME *.sql
rm ./*.sql
scp ./backups/$FILENAME [email protected]:backups/

Just save it in a file, and add it to your cronjob (crontab -l) I run it every 4 hours, by adding this to my crontab:

0 */4 * * * /home/user/db_backup.sh

 

git-ftp connecting but not uploading

I’m working on a small project for a client who uses a shared hosting environment. In order to use some sort of versioning,  I setup git-ftp so I can work on my development server and push the changes with git-ftp to the shared hosting ennvironment. This way I will not need to do any manual file picking and uploading. After the first git-ftp init command (where it will upload the complete folder) you can git-ftp push, so it will only push the changed files from the commits.

 

I had a small hickup setting it up, the git-ftp init would hang for 15 minutes and then display an error, so I ran it again with git-ftp init -v to see what was going on, turns out it connected but default git-ftp tries to use epsv connection, which wasn’t supported, so it was just connecting showing connected, with last message TYPE A, and them  waiting for a response and timing out after a set time.

in order to run in PASV mode directly you can use git-ftp init –disable-epsv