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.