Skip to content

Commit c7ff588

Browse files
committed
Tidy up backup page, following raspberrypi#191
1 parent edfddaa commit c7ff588

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

linux/filesystem/backup.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Here we'll guide you through some backup techniques for your Raspberry Pi system
88

99
A sensible way to keep your home folder backed up is to use the `tar` command to make a snapshot archive of the folder, and keep a copy of it on your home PC or in cloud storage. To do this enter the following commands:
1010

11-
```
11+
```bash
1212
cd /home/
1313
tar czf pi_home.tar.gz pi
1414
```
@@ -19,26 +19,26 @@ This creates a tar archive called `pi_home.tar.gz` in `/home/`. You should copy
1919

2020
If you have MySQL databases running on your Raspberry Pi, it would be wise to keep them backed up too. To back up a single database, use the `mysqldump` command:
2121

22-
```
22+
```bash
2323
mysqldump recipes > recipes.sql
2424
```
2525

2626
This command will back up the `recipes` database to the file `recipes.sql`. Note that in this case no username and password have been supplied to the `mysqldump` command. If you do not have your MySQL credentials in a `.my.cnf` configuration file in your home folder, then supply the username and password with flags:
2727

28-
```
28+
```bash
2929
mysqldump -uroot -ppass recipes > recipes.sql
3030
```
3131

3232
To restore a MySQL database from a dumpfile, pipe the dumpfile into the `mysql` command; provide credentials if necessary and the database name. Note that the database must exist, so create it first:
3333

34-
```
34+
```bash
3535
mysql -Bse "create database recipes"
3636
cat recipes.sql | mysql recipes
3737
```
3838

39-
Alternatively, you can use the `pv` command (not installed by default, so install with `apt-get install pv`) to see a progress meter as the dumpfile is processed by MySQL. This is useful for large files:
39+
Alternatively, you can use the `pv` command (not installed by default, so install with `sudo apt-get install pv`) to see a progress meter as the dumpfile is processed by MySQL. This is useful for large files:
4040

41-
```
41+
```bash
4242
pv recipes.sql | mysql recipes
4343
```
4444

@@ -48,29 +48,28 @@ It may be sensible for you to keep a copy of the entire SD card image, so you ca
4848

4949
In Linux or Mac, for example:
5050

51-
```
51+
```bash
5252
sudo dd bs=4M if=/dev/sdb of=raspbian.img
5353
```
5454

5555
This will create an image file on your PC which you can use to write to another SD card, and keep exactly the same contents and settings. To restore or clone to another card, use `dd` in reverse:
5656

57-
```
57+
```bash
5858
sudo dd bs=4M if=raspbian.img of=/dev/sdb
5959
```
6060

6161
These files can be very large, and compress well. To compress, you can pipe the output of ```dd``` to ```gzip``` as well to get a compressed file that is significantly smaller than the original size:
6262

63-
```
63+
```bash
6464
sudo dd bs=4M if=/dev/sdb | gzip > rasbian.img.gz
6565
```
6666

67-
To restore, pipe the output of ```gunzip``` to ```dd```:
67+
To restore, pipe the output of `gunzip` to `dd`:
6868

69-
```
69+
```bash
7070
sudo gunzip --stdout rasbian.img.gz | dd bs=4m of=/dev/sdb
7171
```
7272

73-
7473
See more about [installing SD card images](../../installation/installing-images/README.md).
7574

7675
## Automation

0 commit comments

Comments
 (0)