1er commit
De la docs au format Mkdocs
This commit is contained in:
98
docs/Raspberry/backup.md
Normal file
98
docs/Raspberry/backup.md
Normal file
@@ -0,0 +1,98 @@
|
||||
# Backup
|
||||
|
||||
### Avec sshpass (MdP en clair)
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install sshpass
|
||||
```
|
||||
|
||||
```bash
|
||||
\#!/bin/bash
|
||||
|
||||
sudo sshpass -p "password" rsync -avzO --exclude='@eaDir' -e ssh bruno@192.168.1.7:/var/services/homes/bruno/CloudStation/Drive/Raspberry :/var/services/homes/bruno/CloudStation/Drive/Unix /home/pi/Documents
|
||||
```
|
||||
|
||||
Sauver avec CTRL-O (Return) et quitter avec CTRL-X (Return)
|
||||
|
||||
### Par clé
|
||||
|
||||
```bash
|
||||
$ ssh-keygen -t rsa -C pi@framboise
|
||||
|
||||
$ cat ~/.ssh/id_rsa.pub | ssh bruno@192.168.1.7 -p42666 'cat >> .ssh/authorized_keys'
|
||||
```
|
||||
|
||||
```bash
|
||||
\#!/bin/bash
|
||||
|
||||
rsync -avzO --exclude='@eaDir' -e ssh bruno@192.168.1.7:/var/services/homes/bruno/CloudStation/Drive/Raspberry :/var/services/homes/bruno/CloudStation/Drive/Unix /home/pi/Documents
|
||||
|
||||
\# option -O pour éviter l’erreur:
|
||||
|
||||
\# rsync: failed to set times on "/home/pi/Documents/Unix": Operation not permitted (1)
|
||||
```
|
||||
|
||||
Sauver avec CTRL-O (Return) et quitter avec CTRL-X (Return)
|
||||
|
||||
Rendre le script exécutable
|
||||
|
||||
```
|
||||
$ sudo chmod +x /home/pi/sync.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Ajouter le script à cron:
|
||||
|
||||
Créer une crontab pour l'utilisateur pi
|
||||
|
||||
```bash
|
||||
pi@framboise:~ $ crontab -u pi -e
|
||||
|
||||
no crontab for pi - using an empty one
|
||||
|
||||
Select an editor. To change later, run 'select-editor'.
|
||||
|
||||
1. /bin/ed
|
||||
2. /bin/nano <---- easiest
|
||||
3. /usr/bin/vim.tiny
|
||||
|
||||
Choose 1-3 [2]: 2
|
||||
|
||||
crontab: installing new crontab
|
||||
```
|
||||
|
||||
Editer la crontab utilisateur (pi)
|
||||
|
||||
```bash
|
||||
$ pi@framboise:~ $ crontab -e
|
||||
```
|
||||
|
||||
Ajouter la ligne
|
||||
|
||||
`*/5 * * * * /home/pi/Documents/sync.sh >> /home/pi/sync.log 2>&1`
|
||||
|
||||
Le script sync.sh est exécuté toutes les 5mn.
|
||||
|
||||
STDOUT est redirigé sur sync.log et STDERR aussi.
|
||||
|
||||
Redirection du flux de sortie (STDOUT): >/dev/null
|
||||
|
||||
Rediriger uniquement STDERR: 2>/dev/null
|
||||
|
||||
Rediriger STDERR là où est redirigé STDOUT: 2>&1
|
||||
|
||||
Si les sorties ne sont redirigées, erreur dans /var/syslog
|
||||
|
||||
```bash
|
||||
CRON[8380]: (CRON) info (No MTA installed, discarding output)
|
||||
|
||||
(pas de Mail Transfer Agent, ie Postfix, Mutt…)
|
||||
```
|
||||
|
||||
Lire la crontab utilisateur (pi)
|
||||
|
||||
```bash
|
||||
pi@framboise:~ $ crontab -l
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user