Backup Of Files and Database on MediaTemple Grid Server

The goal here is to have a cron job run which will start a backup of database and all the files located on the server. Following this, I can set my NAS server at a different physical location to download the compressed backup.

Step 1: Create a SH file which will run the tasks I mention above. I used the file name ‘backupall.sh’ and placed it on my MediaTemple Grid Server in the /data/ folder, which has a full location as /home/######/data/.

Step 2: Add this code. Note, you will need to change the ###### to your Grid server number and add password to mysql download command. Also note, I created a folder /backup-domains/ at /home/######/data/ to store all my backups.

#!/bin/sh
echo "############### Backing up files on the system... ###############"
echo "Started at:"
date
 
backupfilename=server_file_backup_`date '+%Y-%m-%d'`
 
echo "----- First do the sql by deleting the old file and dumping the current data -----"
rm -f /home/######/data/tmp/backup.sql
mysqldump -udb###### -pMY-PASSWORD -hinternal-db.s######.gridserver.com --all-databases --add-drop-table > /home/######/data/tmp/backup.sql
echo "## Completed mysql backup ##"
 
echo "----- Now tar, then zip up all files to be saved -----"
tar cvf /home/######/data/backup-domains/${backupfilename}.tar /home/######/domains/* /home/######/etc/php.ini /home/######/data/tmp/backup.sql
gzip /home/######/data/backup-domains/${backupfilename}.tar
rm /home/######/data/backup-domains/${backupfilename}.tar
chmod 666 /home/######/data/backup-domains/${backupfilename}.tar.gz
echo "## Completed data backup ##" 

echo "Completed at:"
date 
echo "############### Completed full backing up system... ###############"

Explained slightly:

  1. backupfilename – is creating a file name which includes the current date.
  2. rm & mysqldump – are removing previous backup (which actually has already been compressed and added to files) and exporting all the databases on my server.
  3. tar – is creating a .tar file backup of all domains, my php.ini, and above mysql database file. If you have other important files you want to add they should be placed at the end of this line.
  4. gzip – takes that tar file and compresses it into a new gzip file.
  5. rm – is removing the tar file since gzip now exists.
  6. chmod – changes the permissions to allow transferring this file.

Step 3: Create a file for logging all steps and errors (if they happen). I did this in the same folder, /home/######/data/ and named it ‘backup_log.txt’. I also changed the permissions to full write for group to avoid any permission errors from cronjob.

Step 4: Add the cron task to Media Temple (mt) Account Center. Go to the ADMIN -> FILE MANAGER block -> CRON JOBS. Select ‘Add Cron’ and place a sentence like this there:

/home/######/data/backupall.sh > /home/######/data/backup_log.txt 2>&1

The above will overwrite the log each time it is run, in my case that is preferred because it adds 6mb each run. But if you want to record all history add another ‘>’ like this:

/home/######/data/backupall.sh >> /home/######/data/backup_log.txt 2>&1

You are welcome to use this at your own risk. The code above was adapted from geekyboy.com for use on Media Temple Grid server.

PrestaShop PayPal button

If you want to edit the PayPal button in Prestashop, the location for me was:

/modules/paypal/views/templates/hook/express_checkout_payment.tpl

The code that is not being translated was:


{$PayPal_content.payment_choice}

Adding Hreflang Tag to PrestaShop

I notice Google Webmaster Tools talking about Hreflang Tag and found this great resource in explaining it:
moz.com – Hreflang Tag

Next step was to have the code added to my language links.

First get or understand the right codes:
The hreflang Tags Generator Tool

Once I understood that, I needed to add it to the language module in PrestaShop. The location was /themes/theme-name/modules/blocklanguages/blocklanguages.tpl

In my case, I added this: The $ is pulling the requested language iso code and I added the ‘-jp’ because the site is only serving customers in Japan but in different languages. After the ‘-‘ should be the country from my understanding.


hreflang="{$language.iso_code}-jp"