backup

How to use the Linux ‘scp’ command without a password to make remote backups

Summary: How to create a public and private key pair to use ssh and scp without using a password, which lets you automate a remote server backup process.

Over the last two years I've ended up creating a large collection of websites and web applications on a variety of Linux servers that are hosted with different companies like GoDaddy and A2 Hosting. I recently embarked on a mission to automate the backup processes for all these sites, and as a result of this effort, I thought I'd share what I've learned here.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

How to make a backup copy (ISO) of a CD or DVD using the MacOS dd command

Table of Contents1 - Step 1: Insert a CD or DVD2 - Step 2: Find the CD/DVD identifier3 - Step 3: Unmount the drive4 - Step 4: Copy the DVD with the dd command5 - Step 5: Eject your media

If you want to make a backup copy (an ISO image) of a CD or DVD on a MacOS system using the dd command at the Mac Terminal command line, I’ll demonstrate the process in this tutorial.

Back to top

Step 1: Insert a CD or DVD

Assuming that you’re using an external CD/DVD drive, the first step is to connect your drive to your computer, and then insert a CD or DVD. If you insert a movie or music CD and an application automatically starts playing, quit that application.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Unix: How to find files with multiple filename extensions

As I mentioned in my How to find multiple filenames with Linux find tutorial, you can use find command syntax like this to find files with multiple filename extensions:

find iTunes \( -name "*.mp3" -o -name "*.m4a" \)

As that command shows, I ran this find command to find all of my music files under my iTunes directory, including .mp3 and .m4a filename extensions.

While I’m in the neighborhood, this is the full find command I use to backup all of my iTunes files that have changed or been added in the last 180 days:

find iTunes \( -name "*.mp3" -o -name "*.m4a" \) -type f -mtime -180 -print0 | xargs -0 tar rvf NewMusic.tar

There’s probably an easier way to do this, but that backup command works for me.

How to make an offline mirror copy of a website with wget

As a short note today, if you want to make an offline copy/mirror of a website using the GNU/Linux wget command, a command like this will do the trick for you:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Complete backup scripts for my websites (Drupal, MySQL)

I’m spending a little time today trying to automate the process of backing up my websites, and in doing so I thought I would share the Linux shell scripts that I use to generate the backup files, including backups of my MySQL databases and Drupal website directories. If you are comfortable with shell programming in Linux, I think you’ll be able to follow the code in the following scripts.

MySQL database backup script

First, this is a backup script I use to backup a MySQL database:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

MySQL backup - How to backup a MySQL database

MySQL database FAQ: How do I backup (back up) a MySQL database?

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

MySQL restore: How to restore a MySQL database from a backup

MySQL database FAQ: How do I restore a MySQL backup? (Also written as, "How do I restore a mysqldump file?")

Assuming that you’ve created a MySQL backup file as shown in my “MySQL backup - How to Backup a MySQL database” tutorial, you can use the commands shown here to restore your MySQL database.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Mac backups - handling spaces in filenames with find, tar, and xargs

This morning I decided to take a few minutes to backup all the songs I've purchased over the last half-year. These are all on my Mac OS X system, under the Music folder in my home directory.

The problem with trying to do this with standard Unix tools is that all these subdirectories and filenames have spaces in their names. Just looking at the Music folder, it contains many directory names like this:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

A MySQL database backup (mysqldump) shell script

MySQL database backup FAQ: Can you share a Linux shell script that I can use to make a MySQL backup (i.e., a shell script that wraps the mysqldump command)?

I currently have a collection of websites on several different servers (including GoDaddy and A2 Hosting web servers), so I was just spending some time trying to automate my MySQL database backups. To that end, I just created a MySQL shell script that I use on each Linux server to make my database backups, and I thought I'd share that script here.

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Use sed to modify files in place

sed command FAQ: How can I use the Unix/Linux sed command to edit (modify) files in place?

The short answer is that you just need to use the -i or --in-place sed arguments, as shown in the sed man page:

-i[SUFFIX], --in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)

Then, if you have a file named 'hello.txt' with contents like this:

jello, world
this is a test

you can then run a sed command like this to modify that file:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.