VBS Script to Delete Old Files

by Dan | Comments Off

scriptsI have setup my web hosting service to FTP my full backup of my website every Monday.  While this automation is great I forgot about one thing to maintain.  With each one of these backup files being about 1GB it can start to take up a lot of space if you do not clean up your older files!

So after searching around I came around the .vbs script that looks at the directory and deletes any file older than a specified number of days.  In this case I have chosen 60 days.  Now a few things to remember, make sure you keep backing up your site if you are running this file otherwise you will delete all of your backups if it is long than 60 days since your last backup!  Using Windows scheduler I have made this run shortly after I receive my latest backup file from my web host.  This makes my backup process totally automated now even for maintaining files!

Delete Files Older than 60 Days

Automated CPanel Full Backups

by Dan | Comments Off

cpanel_logoLooks like I finally figured out how to automate cpanel backups.  Since most of my sites are all hosted on the same account backup was a sinch with cpanel full backup.  Only issue was that I could not automate the task until now!

First I setup my own local FTP so I had a remote place to put the files.  Then using the script below edited it put in my cpanel variables and then created a cron job to run the file.  The issue wasn’t finding this script, I have had it for a while, the issue was getting the darn thing to work.  Looks like what I was missing was changing the $skin parameter to ‘lp’…thank you Lunar Pages Forum (yes should have looked there a long time ago but didn’t).  Lunar Pages would be my host and looks like they have their own skin for cpanel.  Once I got that in place everything worked perfectly and then I just scheduled the cron job below.

Here is the script cpanel_backup.php

Then schedule the script job via Cron
0 0 * * 1 /usr/bin/env php cpanel_backup.php

MySQL Dump and Load Commands

by Dan | Comments Off

logo-mysqlI have had to do this a lot lately with all the database work I have been doing so I figured I would write this down before I forgot about it.

If you need to restore a database from a .sql file here is the command:

mysql -h hostname -u username -pthepassword databasename < dumpfile.sql

If you need to dump a database to a file (for automated backup purposes) you can use this command:

mysqldump -h hostname -u username -pthepassword databasename > backup-file.sql

These can be very helpful when doing database work

System Automation

by Dan | Comments Off

systemcleanupSo I have decided to resurrect an old laptop that I had sitting in my office for about 2 years.  Well after $40 to quadruple the memory and replacing the hard drive and then re-installing XP from scratch and then all the manufacturer drivers, we finally are in business.  I then plugged this into my network and our LCD TV and the stereo.  So it is our own little home entertainment system for our TV.  Well I decided that since this thing would be on 24/7 that I needed to do some automation to some tasks to keep it clean.  Because Playon and Hulu and other web based tools like to create awesomely large temp files that just hang around if you do not delete them.  Also because it is a WindowsXP machine I figured scheduling a daily reboot wasn’t a bad idea either.  Well turns out these are all very simple things to automate and then schedule.

For CCleaner you just need to run it in the silent mode by creating a schedule that kicks off ‘CCleaner /AUTO’

For JKDefrag you just need to schedule to run the JKDefragCMD file

For a scheduled reboot you just need to schedule a job that kicks off ‘Shutdown.exe -r -t 00′

Lifehacker has a great article on other processes you can automate but these were the first three I went after to keep my computer clean.  I scheduled CCleaner and JKDefrag on my work laptop and it really does keep things clean and moving along a whole lot better!