Posts Tagged ‘nano’

Super Simple WordPress Backup Program

Whatever you do with your computer, it’s absolutely vital to back up your data. Never is this more true than when you’re administering a website, where creating backups should be a well organised and regular procedure.

This site is no exception to that rule, so to help me out with my daily backups I’ve written a small program in the Python programming language which automates the process of archiving daily snapshots of my site. For peace of mind, I still prefer to launch and organise backups myself rather than use completely automatic solutions; this program helps make that process much quicker.

Download

You can download the program by right-clicking here and pressing ‘Save As’/’Save Target As’.

If you want to download straight to your Linux machine from the command line, use wget:

$ wget http://zebpedersen.co.uk/python/wordpressbackup

The program is designed to run under Linux, but theoretically it will work on any Unix system (Mac OS X, Solaris etc…) with Python installed.

Operation

All you need to feed the program is the path to your WordPress installation (the directory containing your wp-****.php files). The database login credentials are borrowed from WordPress, and the backup is placed in a date-stamped folder for easy archiving.

Each backup contains a dump of your MySQL database and a tarball of your installation directory – everything you need to restore your site in case of a disaster. The backup will be created in the folder from which you start the program.

To launch the program:

$ ./wordpressbackup /path/to/wordpress/installation

For example, if your site is located in the directory ‘/home/randymarsh/web’, the command would be:

$ ./wordpressbackup /home/randymarsh/web

If you need help or more information, use the help & about functions:

$ ./wordpressbackup help

$ ./wordpressbackup about

Hopefully this little script can help out anyone else like me who only trusts a backup they’ve done by hand. Enjoy!

 

Tutorial Series: Linux Command Line Basics

Last week, I published a seven part series of posts introducing some of the key concepts, commands and techniques of the Linux/Unix command line. Here’s an index of the topics covered to help you find what you’re after.

 

Full Screen Terminal in Mac OS X

It seems that I’m not the only one who finds the tinsel of an operating system GUI distracting when I’m trying to concentrate on some work. While many Linux distributions allow you to fullscreen a Terminal window, Mac OS X’s Terminal.app does not provide you with such an option. Although I did (briefly) consider rebooting into single-user mode (which starts OS X with a BSD shell), it seemed like a better idea to try and find out if anybody has already had the same thought as I, which led me to a great solution over at http://www.hccp.org

In order to enact this process yourself you’ll need X11 and the Mac OS X Developer tools installed.

(more…)

Linux Command Line Basics Part IV: Useful Command Line Tools

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. In Part 4, I’ll introduce some command line tools which cover some of the most common and most useful functions in Unix.

Really Useful Unix Command Line Tools

Unix operating systems come as standard with a number of very helpful command-line tools which perform very common and very useful file and and administration functions quickly and easily. Here’s a list of some oft-used programs:

System Monitor – top

top provides a real-time updated list of the top processes running on your Unix system. It is similar in function to ‘Task Manager’ on Windows and ‘Activity Monitor’ on Mac OS X. To quit ‘top’, press ‘q’.

'top' running on a Linux server

(more…)

Web & Coding Tools for Mac OS X

Here’s three essential tools for anyone who uses Mac OS X for coding or remote admin.

FTP: FileZilla

If you work on a remote machine of any sort the chances are you’re going to need to send files to and from your local terminal.

FileZilla is not just the best open source FTP client I’ve ever used, it’s the best FTP client I’ve ever used period – it’s fast, free and dead easy to use, as well as being available for all three major platforms. I can’t recommend the Mac OS X version highly enough – it’s essential.

You can grab the latest version of FileZilla here, and remember, it’s donation-ware so if you love it, hit up PayPal and help out.

 

 

(more…)

Adding a Custom Error Page when Hosting Multiple Sites Using Apache

Another optional extra you might want to consider when hosting multiple sites, or just when working with subdomains, is a custom error page.

Using the more basic configurations detailed in previous tutorials, you may occasionally find odd results being returned to your clients. For example, if someone were to simply type your server’s IP into their browser, or spelled a subdomain incorrectly, Apache2 will serve them up the first site it finds in its configuration path. If you’re hosting multiple sites, this means that a totally different site might be returned, which doesn’t exactly look professional.

Here, I’ll show you how to easily counter this problem, by creating a custom error page for your server.

[If you’re not familiar with Apache configuration files, read one of the tutorials linked above for more info.]

Step One

Create your custom error page and save it as ‘index.html’. In this example, we’re going to create the ‘index.html’ file at /home/randymarsh/errorpage/index.html.

This page could just be an image or some text, or you can write a redirect to one of your hosted sites or their subdomains. As long as it’s called ‘index.html’, you can do what you want here.

(more…)

Hosting Multiple Sites on the Same Server Using Apache2

When I upgraded to my new server (Lumpy Gravy) and migrated my own site from my trusty HP DL380 to the new box, I took the opportunity to get better acquainted with one of the cornerstones on the internet, a piece of software you rarely ‘see’ but operates behind the scenes not just of this site but a full 59% of the entire internet – the Apache web server.

Apache2 comes as part of the ‘LAMP’ packages you are given the option to install when loading Ubuntu Server, and by forwarding port 80 to your machine you can start hosting web content quickly and easily.

But what if you wanted to host multiple websites from the same server? This is something I’ve had to do for the first time this week, and it’s all possible with a few simple configuration changes to Apache.

(more…)

Running Dropbox Under Debian Linux

I’ve been using a Debian desktop machine recently for some development work and had a few problems installing one of my favourite applications: Dropbox.

Dropbox.com provides a .deb package for easy (as Linux ever is) installation on any Ubuntu desktop machine, however a dedicated Debian installation package is missing. Ubuntu is, of course, a Debian derived Linux distro, and this package really should work. Unfortunately, no matter how many times you try and install the package, it’ll throw up a dependency warning about libnautilus – even if you’ve got the latest version.

Even if you build the program from source, it doesn’t want to install. Luckily I found this solution, reproduced here (hopefully a bit clearer).

  1. Download the Dropbox .deb file for x86 or AMD64 from the Dropbox downloads page to your Downloads folder. Open a terminal window and navigate to where you’ve downloaded the file.
  2. What we need to do to solve the dependency problems is edit one of the installation configuration files within the .deb package. In order to do that, we’re going to extract it to a new folder. At the command prompt, create a new folder:
    mkdir -p extract/DEBIAN
  3. We now need to extract the package to the new folders we created. Enter the following two lines:
    dpkg-deb -x nautilus-dropbox_0.6.7_i386.deb extract/
    dpkg-deb -e nautilus-dropbox_0.6.7_i386.deb extract/DEBIAN/
  4. Using your favourite text editor (mine is nano), open the file extract/DEBIAN/control. We need to edit one of the lines in this file to make it compatible with regular Debian.
  5. On the line beginning ‘Depends:', find ‘libnautilus-extension1 (>= 1:2.22.2)'
  6. Remove the ‘1:' from this line, so the section now reads ‘libnautilus-extension1 (>=2.22.2)'. Ubuntu’s libnautilus packages are reported using the 1: format, whereas Debian’s are not.
  7. Navigate back to your root folder and create a ‘build’ folder:
  8. Now, rebuild the .deb package using the following line:
    dpkg-deb -b extract/ build/

You can now proceed to install this package as normal.

Nano Defaults ~/.nanorc

I’ve been fiddling more with Linux on the Xbox, and one really annoying bug I was confronted with was the reversal of the backspace function in nano, turning the (very useful) backspace key into a (very annoying) delete key.

nano allows this to be reversed by starting using the “-d” option when you launch, but that’s just so very annoying.

There is, however, an alternative. Like bash and others, nano has a default/startup script file located in ~/, called nanorc. This page has a list of all the options you can set, and all you have to do is add them to the ~/.nanorc file.

Backspace, and order, is restored.