Tag Archives: backup

How to create a Plesk Backup from the command line in CentOS

Plesk-LogoEven in Plesk 12 we can only schedule a single backup, and we must decide where said backup should be saved: either on the local server, or on an off-site FTP server. Sadly we can’t have it both ways.

Many of us – me included – find this very limiting.

Both local and remote backups have their advantages though, and greedy as I am I want the best of both worlds:

  • an FTP backup is stored off-site, which is great for disaster recovery.
  • but a local backup can be create and to restore much faster, which is great for development
  • a local server wide backup creates individual domain backups automatically, whereas an FTP backup does not – great for convenience

The good news is that Plesk has a set of command line tools which we can use to create a backup manually. In this scenario you can schedule a local backup in the Plesk web interface, and create another one using a cron job.

The tool I’m talking about is called pleskbackup and it lives in the Plesk utilities directory. On CentOS this is in /usr/local/psa/bin.

If called without parameters you’ll see a long list of options you can pass to this command:

Usage Example: Local Backups

To create a local server-wide backup, all we have to do is this:

This will create a backup just like the Backup Manager would in the Plesk web interface. Those are stored in a variety of files in /var/lib/psa/dumps and also in the respective domains/resellers/customers directories.

To create a single domain backup, simply replace “server” with “domains-name yourdomain.com” like this:

Add more domains on the same line, separated by spaces.

Usage Example: FTP Backups

FTP backups are slightly more complex to create. We must pass all our credentials as part of the –output-file parameter, which requires us to specify a file name. Since the tool will create a .tar file, make sure you add this as part of your file name. Let’s look at a full example.

Imagine we’d like to create a server wide backup, and our FTP credentials are

– server (FTP Host)
– user (FTP User Name)
– password (FTP Password)
– filename.tar (our backup file name)

then we can call the command like this:

If all goes well you’ll receive no feedback. This is a synchronous task which on larger installations can take several hours – but it should be done within seconds on systems with dummy domains.

First the tool creates a local backup, then ZIPs up the tarball and sends it to the FTP server. Once finished, the tool comes back to the command line.

Automatically deleting older backups from FTP

I love how the Plesk Backup Manager takes care of older backups and deletes them automatically. The pleskbackup command line tool on the other hand isn’t so friendly and instead is a low-level command that only does one thing. If we’d like to see automatic deletions we’ll have to employ a script that will do this for us.

I’ve written such a script in PHP and put it on GitHub – feel free to examine it, test it, use it, redistribute it:

  • https://github.com/versluis/Plesk-Backup

To use the script, take a look at the top of the file and amend your details accordingly:

Save your changes and make sure you add execute permissions to the file:

Now you can call the file from the command line or via a Cron Job (Scheduled Tasks in Plesk). Execute the script as root and make as many backups as you like – in addition to what Backup Manager is doing from the web interface.

The one caveat I found is that the pleskbackup tool does not maintain the correct timestamp when it copies the tarball over to the FTP server. It’s an issue with pleskbackup rather than my script – I don’t understand how Backup Manager can do this fine in the web interface, which presumably relies on the same tool.

As a workaround I’m saving the date as part of the filename, i.e. BACKUP-YYYYMMDD-HHMMSS.tar. For the auto-deletion to work, make sure to use a dedicated directory for your FTP backups with no other files – otherwise the latest backup may be deleted.

To save your backups in a subfolder, amend the prefix like this:

And that’s how we can create Plesk backups from the command line!

How to change the default directory for backups in Plesk

Plesk-LogoBy default the Backup Manager in Plesk stores local backups in /var/lib/psa/dumps.

You can change this location by editing /etc/psa/psa.conf. Find the following block in the file:

Change the path for DUMP_D to your new desired location, then restart Plesk for the changes to take effect:

Alternatively, if you don’t want to make the change, you can mount another volume to the default backup directory (such as an Amazon S3 Bucket).

How to backup and restore your WordPress site with Plesk

In this podcast I’ll show you how to backup and restore your website with Plesk 11.5.

Backup and Restore in Plesk can be very easy and straightforward – and it’s fantastic when it works. There are cases though when it does not, so here are few things to keep in mind.

  • Automatic backups may fill up your disk space if they’re not automatically deleted.
  • Email notifications may arrive with delay. If you have the time, use the “refresh”option in Plesk and keep an eye on it yourself.
  • FTP backups to other servers can be very temperamental. Anything over 1GB in size may time out on its way to the FTP server, in which case you’ll get an error message and a local backup only. I did not cover FTP backups in this podcast.

As you can imagine, we’ve only scratched the surface of this feature. Feel free to ask questions below, or check out the Plesk Documentation here:

  • http://www.parallels.com/download/plesk/11.5/documentation/

How to fix permission problems when restoring folders from Time Machine Backups

Airport TimeCapsuleI had an odd problem the other day: I wanted to restore a fairly large folder from my new AirPort TimeCapsule. But the restore always stopped at one particular file, with an error message about permission problems.

The folder in question was about 4GB in size and contained just over 10.000 files in total. I was baffled! Time Machine had never failed me before, so what was going on out of a sudden?

Well I guess it’s a computer, and things just go wrong sometimes. Thanks to Apple Support this problem is now solved – and I thought I’d share the insight, both with you all and my future self.

Continue reading How to fix permission problems when restoring folders from Time Machine Backups

How to backup WordPress

In this podcast I will show you how to backup a full WordPress installation. This includes your files and your database.

It’s not a tough task, but you need to know how to do it. We will be using FileZilla and phpMyAdmin for this. Have your credentials ready (you’ll get those from your hosting provider).

We will discuss how to restore your WordPress site in the next podcast.