How to export/import a XenServer VM from the Command Line

We can list the VM’s by running

xe vm-list

You can export a VM using either the name of the VM or by using the uuid.  The above command list both so you can use which ever one you want.

You will also need to shutdown the VM your going to export.

xe vm-shutdown vm=ubuntu

Export by Name
The name of the VM is”ubuntu”.

xe vm-export vm=ubuntu filename=/backup/ubuntu.xva

Export using uuid

xe vm-export uuid=b24dcd65-5e12-4576-2f39-46ecab9362ab filename=/backup/ubuntu.xva

Importing VM

xe vm-import vm=centos5 filename=/backup/ubuntu.xva

Create an Image of a SD Card

The following command works on both OS X and Linux.  It creates an image from the SD card called raspi.img which you can later use to clone to another SD Card or just keep as a backup.  It is exceptionally useful for backing up a Raspberry Pi.

Replace “mmcblk0” with your SD cards name.  Take a look at this post if you need help finding the name.

sudo dd if=/dev/mmcblk0 of=~/raspi.img

How to Backup a WordPress Site from the Command Line

There are 2 things we need to do when we backup a WordPress site.

  1. Backup the WordPress files
  2. Backup The WordPress database

Backup the WordPress files

We can backup the files with tar by running the following command.  Replace (/Path/to/wpdir) with the actual path.

#  tar -zcvf wp-backup.tgz /Path/to/wpdir/

This can take awhile depending on how big your site is.

Backup the Database

The following command will backup the WordPress database into a gziped sql file.

mysqldump -u username -p[root_password] database_name > wp-database.sql && gzip wp-database.sql

You can find the MySQL Database, username, and password in the wp-config.php file in the wordpress directory

You should now have two files, wp-backup.tgz and wp-database.sql.qz, you’ll need both of these to restore the backup.