Tagged: backup Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 7:23 pm on September 18, 2014 Permalink | Reply
    Tags: backup,   

    Categories: Plesk ( 76 )   

    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: pleskbackup   [] 
      server         Backs up whole Plesk.
      resellers-name Backs up selected resellers. Reseller's logins are read from command line,
                     space-separated. If no resellers provided, backs up all resellers
                     on the host.
      resellers-id   Backs up selected resellers. Reseller's identificators are read from command line,
                     space-separated. If no resellers provided, backs up all resellers
                     on the host.
      clients-name   Backs up selected clients. Client's logins are read from command line,
                     space-separated. If no clients provided, backs up all clients
                     on the host.
      clients-id     Backs up selected clients. Client's identificators are read from command line,
                     space-separated. If no clients provided, backs up all clients
                     on the host.
      domains-name   Backs up selected domains. Domain's names are read from command line,
                     space-separated. If no domains provided, backs up all domains
                     on the host.
      domains-id     Backs up selected domains. Domain's identificators are read from command line,
                     space-separated. If no domains provided, backs up all domains
                     on the host.
                     Use Exclude options to exclude some resellers/clients/domains.
      help           Shows this help page
    Output file option:
            /fullpath/filename      - regular file,
            -                       - use stdout for output,
            [ftp|ftps]://[[:]@]/fullpath/filename - storing the backup to ftp server.
                           FTP_PASSWORD environment variable can be used for setting password.
                           FTP option '--ftp-login' can be used for setting login.
                           FTP option '--ftp-password' (with '--ftp-login') can be used for setting password.
                           If your password contains slash, you have to use '--ftp-password' option or
                           FTP_PASSWORD environment variable.
                           'ftps' protocol can be specified to use FTP over SSL, instead of plain FTP.
                           With ftps specify 990 port to use implicit FTPS, otherwise explicit mode will be used.
            Used to import dump from repository into the single file.

    Usage Example: Local Backups

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

    pleskbackup server

    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:

    pleskbackup domains-name your yourdomain.com

    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:

    pleskbackup server --output-file=ftp://user:password@server/filename.tar

    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:

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

    // add your FTP credentials here
    $ftp_server = "ftpserver";
    $ftp_user = "ftpuser";
    $ftp_password = "password";
    // maximum number of backup files to keep on FTP
    $maxbackups = 30;
    // add a prefix for your backup
    $prefix = 'BACKUP-'; 
    // PLESK utilities directory
    $pleskbin = "/usr/local/psa/bin/";

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

    chmod +x ./backup.php

    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:

    // add a prefix for your backup
    $prefix = 'subfolder/BACKUP-'; 

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

    • FotoJoerg 4:58 pm on August 26, 2016 Permalink | Reply

      Hi Jay, greetings and many THX from Germany,
      your script made it, makes me happy, works fine !

      So, thank you again for your work and your time to wrote all!


      • Jay Versluis 10:44 pm on August 26, 2016 Permalink | Reply

        Awesome – great to hear!

    • Jazzyc 7:04 am on December 24, 2017 Permalink | Reply

      In windows changes required —>> ‘ (Single Quotes) add ” (double Quotes) else error

      Further script does not run and throws below error. Tried all combinations / Changes

      “The filename, directory name, or volume label syntax is incorrect.”

      • Jay Versluis 11:25 am on January 20, 2018 Permalink | Reply

        Yeah, copy and paste may not be reliable from this article due to HTML formatting and all that. For the latest version of mu script, and suggestions/pull requests, as well as a reliable copy/paste option, please head over to GitHut:

  • Jay Versluis 12:01 pm on March 6, 2014 Permalink | Reply
    Tags: backup,   

    Categories: Plesk ( 76 )   

    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:

    # Backups directory
    DUMP_D /var/lib/psa/dumps
    DUMP_TMP_D /tmp

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

    service psa stopall
    service psa restart

    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).

  • Jay Versluis 4:32 pm on October 22, 2013 Permalink | Reply
    Tags: backup, ,   

    Categories: Screencast ( 87 ), WordPress ( 145 )   

    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:

    • Thomas 4:48 pm on November 8, 2016 Permalink | Reply

      thanks for your post. Today, my Server was installed new, changing from Ubuntu Server 14.04 using Plesk 12.5 to 16.04 using Plex Onyx. When I restored the backup, all my sites, configuration and so on was back up and running.
      My mailserver, my owncloud, and so on.

      However, the wordpress instance of my wife could not be restored. All the data in the webroot is there, but the DB could not be recovered. And I can not seem to make it work.
      Is there any way to make it work again? I used every version of the backup I could think of.

      The error I get is this: Row size too large

      Any help whatsoever is highly apreciated.

      All the best,


      • Jay Versluis 6:41 pm on November 8, 2016 Permalink | Reply

        Hi Thomas, that’s a tricky one. The error sounds like it’s not something generated by Plesk but rather the mysql command that they use to restore the database. If you still have the old server up and running, with the intact database, you can try to export all tables manually and then import them again on the new server. There may be a way to extract the database backup from the Plesk backup, but if restoring that is more successful than what the Plesk script does I don’t know. Have you tried asking in the Plesk forums? https://talk.plesk.com

        • maybeageek 2:58 am on November 10, 2016 Permalink | Reply

          Hi Jay,
          thanks for the response. Curiously I found the solution quicker than I thought. There seems to be a new default setting for various memory sizes in the newer MySQL versions.
          Two settings in /etc/mysql/my.cnf made it possible to import the website and DB using Plesk Backup&Restore function:
          Just added at the bottom of the file.
          All the best,

          • Jay Versluis 9:21 am on November 11, 2016 Permalink

            That’s great news – thank your for sharing, sooner or later I may run into the same problem 🙂

    • Abhijeet Nagre 4:01 am on December 20, 2016 Permalink | Reply

      Will this approach work if I am restoring backup on a different Server?

      • Jay Versluis 7:21 am on December 20, 2016 Permalink | Reply

        Hi Abhijeet, restoring a subscription to another server will only work with FTP backups. In the latest version of Plesk, I believe you also need to give your backup a password so that it can be restored on another server (without a password the restore won’t work – for security reasons).

  • Jay Versluis 11:40 pm on August 10, 2013 Permalink | Reply
    Tags: , backup, File Permissions, , Time Machine   

    Categories: How To ( 36 )   

    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.

    (More …)

    • valamusic1 6:47 am on November 14, 2014 Permalink | Reply

      Hi there, thanks for the info here. I am having the same problem with restoring some music projects from my time machine. I have followed the steps above and the only problem is that the lock icon is greyed out so I am unable to make the changes. Any idea why this might be? Is there a set I might be missing out?
      I was about to call Apple Care but my Apple Care product has just expired, so I’m a little stuck…thanks! 🙂

      • Jay Versluis 8:10 am on November 14, 2014 Permalink | Reply

        Hi valamusic1, that’s really bizarre – I’ve just checked this on Mavericks 10.9.5 and I’m getting the same thing now: the lock icon is greyed out. Perhaps it’s no longer needed because I can apply different permissions to a file or folder just by changing the drop down menu. Maybe this has changed to make our lives easier. Ignore the lock icon and proceed – let me know how it works out for you.

    • valamusic1 12:50 pm on November 14, 2014 Permalink | Reply

      Hi Jay, thanks for coming back to me. Sorry, I should have said I’m running Mountain Lion 10.8.5. I haven’t upgraded to Mavericks isn’t compatible with the music programme I’m running (Logic 8). Unfortunately I am unable to select “Apply To Enclosed Items” as it is also greyed out. This afternoon I repaired the Time Capsule disk using disk utility just incase this might do the trick but unfortunately it’s not worked either.

      • Jay Versluis 1:01 pm on November 14, 2014 Permalink | Reply

        That’s a shame. Here’s something I’ve heard last time I spoke to Apple Support, perhaps it helps you out: whenever you buy another piece of equipment from Apple, Apple Care for your time capsule is automatically extended – it’s a loophole so that your time capsule is always covered. So if you have bought anything with Apple Care, give them a ring and your time capsule *should* be covered, and perhaps the Apple Support team can help you out for free. Good luck!

    • valamusic1 2:38 pm on November 14, 2014 Permalink | Reply

      I’ll look in to that, thanks for the heads up!

    • Alfred N. Bundal 2:42 pm on March 19, 2015 Permalink | Reply

      OMG Thank you soooo much for this. You saved me. I just stumble across this when i lose hope finding the right answer for my problem. Thank you so much. It helped me.

    • Laura Krause 3:22 am on June 28, 2015 Permalink | Reply

      I’m having a similar problem but the solution above doesn’t work. I don’t have the option to “apply to enclosed items” and I don’t know how to fix it.

    • JAck 3:09 pm on March 14, 2016 Permalink | Reply

      Thank you immensely. Never knew you could do the enclosing thing on permissions. Always thought that would be a stick in the mud problem.

    • Mike 10:26 am on January 20, 2018 Permalink | Reply

      The link for Pondini’s instructions is dead. Can you suggest another link?

      • Jay Versluis 11:12 am on January 20, 2018 Permalink | Reply

        Hi Mike, thanks for bringing this to my attention. I’ve just fixed the links in the article.

        Sadly James Pond (owner of pondini.org) died in 2013. Lucky for us, archive.org keeps a record of his marvellous works alive for the foreseeable future. The direct link to his instructions are here.

    • Mike 4:20 pm on January 21, 2018 Permalink | Reply

      Thanks Jay. Sorry to hear about James.

  • Jay Versluis 7:20 pm on February 21, 2013 Permalink | Reply
    Tags: backup   

    Categories: Screencast ( 87 )   

    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.


Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc