You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: linux/filesystem/backup.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Backups
2
2
3
-
It is highly recommended you keep regular backups of any important files. Backups often shouldn't be limited to user files; they could include configuration files, databases, installed software, settings, and even an entire snapshot of a system.
3
+
It is highly recommended that you keep regular backups of any important files. Backups are often not limited to user files; they could include configuration files, databases, installed software, settings, and even an entire snapshot of a system.
4
4
5
-
Here we'll guide you through some backup techniques for your Raspberry Pi system.
5
+
Here, we'll guide you through some backup techniques for your Raspberry Pi system.
6
6
7
7
## Home folder
8
8
9
-
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:
9
+
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:
10
10
11
11
```bash
12
12
cd /home/
@@ -23,30 +23,30 @@ If you have MySQL databases running on your Raspberry Pi, it would be wise to ke
23
23
mysqldump recipes > recipes.sql
24
24
```
25
25
26
-
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:
26
+
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 don't have your MySQL credentials in a `.my.cnf` configuration file in your home folder, then supply the username and password with flags:
27
27
28
28
```bash
29
29
mysqldump -uroot -ppass recipes > recipes.sql
30
30
```
31
31
32
-
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:
32
+
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:
33
33
34
34
```bash
35
35
mysql -Bse "create database recipes"
36
36
cat recipes.sql | mysql recipes
37
37
```
38
38
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:
39
+
Alternatively, you can use the `pv` command to see a progress meter as the dumpfile is processed by MySQL. This is not installed by default, so install with `sudo apt-get install pv`. This command is useful for large files:
40
40
41
41
```bash
42
42
pv recipes.sql | mysql recipes
43
43
```
44
44
45
45
## SD card image
46
46
47
-
It may be sensible for you to keep a copy of the entire SD card image, so you can restore the whole SD card if you lose it or it becomes corrupt. You can do this using the same method you'd use to write an image to a new card, but in reverse.
47
+
It may be sensible for you to keep a copy of the entire SD card image, so you can restore the card if you lose it or it becomes corrupt. You can do this using the same method you'd use to write an image to a new card, but in reverse.
48
48
49
-
In Linux or Mac, for example:
49
+
In Linux or on a Mac, for example:
50
50
51
51
```bash
52
52
sudo dd bs=4M if=/dev/sdb of=raspbian.img
@@ -58,7 +58,7 @@ This will create an image file on your PC which you can use to write to another
58
58
sudo dd bs=4M if=raspbian.img of=/dev/sdb
59
59
```
60
60
61
-
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:
61
+
These files can be very large, and compress well. To compress, you can pipe the output of `dd` to `gzip` to get a compressed file that is significantly smaller than the original size:
0 commit comments