cPanel Automated Backups

Posted on March 18th, 2008 in Bookmarklets by Patrick

I just scratched an itch I've had for a long time - a proper way to backup cPanel accounts from a reseller account. Up until now I've been scripting w get to grab the daily-generated backup of specific accounts every week (imitating what you can do manually by logging into cPanel and navigating to the Backup tab). It was annoying because I had to manually put in the username and password of each account I wanted to backup. What I really wanted was a solution to backup all accounts with minimal fuss.

The solution is a cron job that runs from my reseller account (you don't need SSH access to do this as cPanel gives you access to your crontab). The solution looks like this:

nice -n 19 tar czhf - ~/backups | ssh user@server.com "cat > /cPanel_backups/$(date +\%A).tgz"

My reseller server puts the daily-generated backups into ~/backups. So, all we have to do is tar this up and copy it over to a backup server.

Notes:

  • We give tar the h option so that it stores the contents of symlinked directories in the archive, not real symlinks (the /backups directory in the primary reseller account contains symlinks inside sub-account subdirectories to the real location of eg. mysql snapshots etc..)
  • We compress the entire directory and pipe it across the wire via ssh
  • The backup is stored with the current day of the week in the name, effectively giving us 7-day rotation
  • You should set up password-less SSH access using public/private keys so that the command isn't prompted for a password
  • The above command should be run from cron
  • The backslash escaping of the percentage sign in the date command is necessary when the command is run from cron
  • UPDATE: nice'd the command so that it doesn't consume too many resources and get killed by my provider ;)

As usual, I've documented this for future reference in Paddypedia.

Multiple Columns Bookmarklet

Posted on October 5th, 2007 in Bookmarklets by Patrick

Reading large chunks of text on a widescreen monitor can be a real pain if your eyes have to read across long horizontal lines. That's why newspapers print articles in columns! Ideally, websites should too, at least when you're trying to view them on a large monitor. Obviously you can't expect webpage designers to predict the size of your screen, but if you're using Firefox you can use this simple bookmarklet I wrote to reformat a selection of text (or the whole page) into multiple columns yourself.

How to use it the Multiple Columns Bookmarklet:
This is the link to my Multiple Columns Bookmarklet.

For starters, try it out yourself on this page! Select a few words in the first paragraph of this page and click the bookmarklet link. You should see it magically reformat into multiple columns 200px wide.

Now select two continuous paragraphs and click the bookmarklet link. You should see the entire article reformatted into easy to read columns. Cool huh?

If you want to use the bookmarklet on other pages, bookmark it now. When you're on a page that you want to reformat select the chunk of text and click on the bookmarklet. voila!

If you select text a single paragraph, only that paragraph will be turned into columns. If you select multiple paragraphs, the containing DOM element will be reformated (this isn't perfect but it usually does what you want). If no text is selected when you launch the bookmarklet, the entire page will be turned into multiple columns (that won't look great on my blog, but it's handy on pages with minimal styling)

If you add a keyword such as col to your bookmarklet link (Right Click > Properties), then you can launch the bookmarklet from the location bar by typing col rather than clicking on the link.

Finally, if you provide an argument of max, eg. col max then the maximum height of the columns will be set to the size of your web browser window. This is really handy if you're viewing a long document and you don't want the columns to scroll vertically for miles and miles (by setting the column height the columns will instead continue horizonally, just like a large-format newspaper).

In case you're wondering, the bookmarklet is only intended for Firefox because none of the other browsers have implemented any column-related CSS features.