Backup MySQL via Bash Script

If you run your own LAMP server, you might want to check out this Bash script which perform backups of the MySQL database. The neat little script can be set to run independently or as part of a cron job. All you have to do is provide the backup directory, username, password, hostname and port number.

The backup script is quite simple. It checks if the backup directory exists and creates one if it’s missing. It will then list all databases and performs a MySQL dump of each database ignoring the mysql, information_schema, and test databases. The file is formatted in gzip and then stored in the backup directory.

The backup script can be set to run every day or once a week using cron. The backup will depend on your backup requirements. I recommend testing the backup and restore process to see if it works.

Display Your WAN IP Address

Have you ever wondered how dozens of websites can display your WAN IP address? The script is quite simple. You can probably host it if you have access to a web server. All you need to do is create a PHP file. Place the code below. Save. Upload the file to a web server and run the script. That’s it.

$ip = getenv(REMOTE_ADDR);
echo “Your IP address is:. $ip;