Wikijunior:Raspberry Pi/Raspberry Pi Updates & Backups Tutorial

by Andrew Oakley - Public Domain Jan 2018 www.cotswoldjam.org

Updating your system
You will need a working internet connection. Select the Raspberry menu – Accessories – Terminal. A black box should appear.

These commands will get the list of updated software and then upgrade. You may be asked to type Y to confirm. This can take a very long time, especially on a Pi 1 or Zero!

will uninstall any software which has been superseded by new software. removes any temporary installation files, to free up space on your SD card.

Restart your system with the Raspberry Pi menu – Shutdown – Reboot.

Connect a USB memory stick and find out what it's called on the system
Insert the USB memory stick into a USB port. We need to find out what the USB stick is called, and where it is on the system.



The memory stick may open automatically in File Manager. In this case, you can read the name from the address bar. In this example it is BLUE64GB.

Alternatively, you can find the name by clicking the "Eject" symbol in the top right of the desktop.



In this example, the name is BLUE64GB. It also shows the brand name (SanDisk Ultra Fit) but we don't care about that.

Don't actually eject the USB stick yet! We're going to put some backups on it. There's another way to find the name and location of your USB stick; find out about the  command.

Back up all your files to a USB stick
These commands back up all files in the  directory. This includes all documents, images, Scratch and Python source code files and Minecraft worlds that you have made, but it doesn't include programs that have been installed on the system.

Note how we used  to move from the   directory to the   directory.

This allows us to treat the entire pi directory as a subfolder that we can back up.

We also use the  option to ignore the   subfolder, as this can contain a lot of large temporary web browser files.

It's a good idea to use the date in the name of your backups, so you can quickly find a backup from a particular day. We used 2018 01 27 for 27th January 2018. Putting the year and month first will make it easier to find in a list that's sorted in file name order.

Once we've finished, we use the  command on its own, to return to our   directory. We could have done  which would have done the same thing.

Restore all your files from a USB stick
Insert the USB memory stick into a USB port. Find the .zip file you want to restore using File Manager.

Using the Terminal, restore the files. Note this will overwrite existing files with the older versions.

Back up just one folder
Note that folders beginning with a full stop are sometimes hidden from file listings, but you can still back them up. For example, the Minecraft folder with all your Minecraft worlds:

Restore just one folder
We didn't use, so it will ask before overwriting any existing files.

List all the files in a large .zip backup archive and pick just one file or folder to restore
Although you can use the  command to extract specific individual files, it's easier to use the Xarchiver program. Use File Manager (Raspberry menu – Accessories – File Manager) to open the USB stick and find your .zip file.

Double-click on your .zip file and the Xarchiver program will start.

You can now double-click to open any folder inside the .zip file. Right-click any file or folder and select Extract to recover it.

Click the folder icon beneath "Extract to" to pick a folder to copy the recovered file to. You probably want  which you can either type in, or click the   folder from the list of folders.

If you're just recovering one file, untick "Extract files with full path".

Click the Extract button to recover the file.

Use File Manager (Raspberry menu – Accessories – File Manager) to find the files you've extracted.

Safely remove the USB memory stick


Click the "Eject" symbol at the top-right of the desktop, then click the smaller eject symbol to the right of your listed USB memory stick.

You should see the message "It is now safe to remove your device". You can remove the USB memory stick from the Raspberry Pi now. You can also eject it from the command line – learn about the  command.

Don't keep your backups near your Pi. If your Pi gets lost, stolen, destroyed by fire or eaten by zombies, you don't want your backups to go missing too!

Grandparents, Aunties and Uncles' houses are a really, really good place to keep your backups. Consider having two memory sticks – one to keep at a relative's house, and one to keep in your house. Swap them over every time you visit!

Migrating to a new release of Raspbian
Every two or three years, a completely new release of Raspbian happens. For example, in 2017 we moved from Raspbian Jessie to Raspbian Stretch.

Raspbian is the operating system that runs on most Raspberry Pis. It handles the desktop, most of the programs, the command line and much more. Raspbian is based on Debian GNU/Linux, which names releases after characters from the Toy Story films. Debian is short for "Debra and Ian"; Ian Murdoch created it, and Debra was his girlfriend.

Whilst it is technically possible to upgrade an existing SD card to a new release, it's prone to mistakes, so our advice is to:


 * Back up all your files to a USB stick, as we showed previously in this tutorial
 * Download the new release image, and burn it to a new SD card, as per the instructions here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
 * Restore your files from your USB stick backup, as per this tutorial.

Other top tips
If you have both a Pi Zero or Pi 1, and a Pi 2 or a Pi 3, do all your updates on the Pi 2 or Pi 3. It will be much, much faster. You can usually swap the memory cards between them (unless your Pi 1 has a really, really old version of Raspian – in that case, it won't work on the Pi 2/3 but it won't cause any harm, just put it back).

Using an Ethernet network cable directly plugged into your broadband router can often make downloading updates much faster than WiFi. You can buy a simple CAT5e Ethernet cable from Poundland and other bargain shops, just don't pay more than £5.

Files
The original PDF for this tutorial is available on Wikicommons: