How to backup your DreamHost account and download the backup easily
I normally do a DreamHost backup every month, along with other things that I backup, and then I download all of the files. It is part of my backup strategy, I backup when I do something important to backup, or the normal monthly backup, which is for me and I call it a value added thing for the people whose sites I host.
I don’t enjoy downloading all of the files one by one of course, I rather leave it downloading as I sleep. And I do not handle one single DreamHost account.
My normal process is: open the source code once the backup is done, paste it into Vim, and do some Vim things to end up with a script that downloads everything, and then I run the script.
However, that is not easy to share, or explain how to do. So, for the backup of this month I thought about instead using a simple bash command; something to open the source code, select it all, copy it, and then run the command and end up with a backup. At a very remote location I have a Raspberry Pi with hard disks attached to it, I send the script there, and it gets the backup in that location as well. In there I will just get a file with the page and run the command using
cat instead of
I am going to share that bash command, maybe someone else would like to get his/her backup from DreamHost, so here we go.
Prepare the Backup at DreamHost
First we access the backup area of DreamHost. Where is the Backup at DreamHost? It is at “Billing & Account > Manage Account” then scroll down until you find the option “Back Up Your Account”
We begin the backup process and then wait. We will receive an e-mail telling us that the backup is finished.
Once the backup has been completed, we go back to “Billing & Account > Manage Account” and then scroll down until you find the option “Back Up Your Account”
Now, while we can begin downloading the different files one by one to the place we want, I prefer to run a command to leave it downloading, preferably while I sleep. This is how I do it.
Leave all the files from the Backup of DreamHost downloading
Before we start this, in the terminal, get into the folder that should have the backup files.
Next, check if you have
xclip available, the command uses this. We can check whether we have it installed or not using:
We can install it in Debian based distributions (Ubuntu, Linux mint) using:
sudo apt install xclip
xclip is very simple to use,
xclip -o puts the contents of a file or the output of a command into the clipboard, so we can paste it with Control+V somewhere else.
But in this case we use
xclip -i to get whatever is in the clipboard and, for example, feed that to a command. Once
xclip is there, we can continue.
If you are also copy<pasting the command, you should do that first, copy it and paste the command on the terminal and wait until you copy the source code of the Backup page to run it.
Then, when we are in the page with the list of files to download, we can press Control+U to see the code of the page, then we can select all with Control+A and then we can copy it with Control+C.
This gives us all the links to download, now it is time to feed them to a command.
This command gives all the addresses of all the backup files, now it is time to feed it to
xclip -selection clipboard -o | grep "<a href=.*>" | grep -o '"https:.*"' | sed "s/\&/\&/g" | sed "s/..*\/\([a-z0-9_@\.\-]*\.[tarsql]*\.gz\).*/wget --no-check-certificate --output-document=\1 \0/g" | bash
This will begin downloading all of the files in the folder you are currently in.
If we save the file with the backup, we can use instead of
xclip a simple
cat [file_name] and then pipe the result to the rest of the command, we basically substitute the part of
Yes, it can be done using the terminal of a Mac computer, now that I have one available I will publish that at another time. The command needs some adjustments in the Mac.
Normally I create folders for the backups named "yyyy-mm-dd", as in "2022-07-01". All of these folders inside one named "Dreamhost", inside a folder named "backups". Just for consistency.
With that style of naming the folders, you can either order them by date of creation, or by name, both will result in the folders ordered.