As part of monthly services, DESIGNLEDGE offered weekly site backups to our clients. The process was time consuming and tedious. For each site, I would open a database connection and perform a SQL dump, sftp into the site and transfer critical directories to my local machine and zip everything into an archive. After that, I'd need to log into the Client Manager and click a button to report the backup to our clients.
After doing this once I was sick of the process.
I decided to write a command-line tool to automate the backup process. The tool reads from a JSON configuration file containing all the sites to back up, their IP addresses, their ssh and database credentials and various other points of data. For each site in the configuration, the tool opens an ssh connection, creates a SQL dump file and transfers it to my local machine.
It then creates a tar archive of the entire website source files and downloads that as well. It puts everything in a directory with the current date and timestamp, then connects to the Client Manager to report to the client Dashboard that the backup was performed.