Create timestamped website backups


Browse by products and services

  • Applies to: Grid
    • Difficulty: Medium
    • Time: 10 minutes
    • Tools needed:¬†SSH, Basic Command-Line Knowledge, VI or VIM

Overview

This article will walk you through how to create timestamped website back-up of your website on the Grid.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Steps

  1. Decide which domain you want to back up then go to that directory.

    cd domains/example.com
  2. Use VI or VIM to create a new file named 'backup.sh':

    vim backup.sh
  3. Add the following information into the file, replacing the placeholders with your domain, and then save:

    #!/bin/sh
    cd ~/domains/example.com
    zip -r backup`date '+%Y-%m-%d'`.zip html/*
    
  4. Run a command which will make the file executable by you, the owner:

    chmod 744 backup.sh
    
  5. Just to make sure it works, test it out:

    ./backup.sh
  6. You should see lines appearing on the screen as each file and folder is added to the archive. They will look something like this:

    adding: html/Media.php (deflated 24%)
    adding: html/Temple.txt (deflated 61%)
    adding: html/Totally.ico (deflated 44%)
    adding: html/Rocks.mp3 (deflated 68%)
    adding: html/Yay/Media/Temple.html (deflated 51%)
    • When you perform a list directory command (ls), you should see a file called "backup08.02.10.zip", or whatever is the corresponding date. So now that we have a working script, it's time to make a regularly occurring job out of it.
  7. From inside the AccountCenter, choose the 'Admin' button and then click 'Cron Jobs'.
  8. Click the 'Add new cron job' button.
  9. Fill out the notification email field. This is important, so you are notified if the cron job fails.
  10. Fill out the "Command or script to execute" field with the full path to your backup. In this example, it will be:

    
    /home/XXXXXX/domains/example.com/backup.sh
    
  11. Choose what time you want the cron job to run. Since this will be a daily backup, you might want to specify 12:00am daily. Or perhaps you would rather back things up at 6:00pm, or at 8:45am; it is up to you.
  12. Once you are satisfied, press the save button.

Resources