# Rsync

### target : krabs (nfs server)

## Synchronisation simple 
```bash
rsync -avh /srv/appdata/ /mnt/backup/appdata/
```

## Synchronisation avec --delete
```bash
rsync -avh --delete /srv/appdata/ /mnt/backup/appdata/
```

## Synchronisation avec --progress
```bash
rsync -avh --progress /srv/appdata/ /mnt/backup/appdata/
```

## Synchronisation avec --partial
```bash
rsync -avh --partial /srv/appdata/ /mnt/backup/appdata/
```

## Synchronisation avec --partial et --progression
```bash
rsync -avh -P /srv/appdata/ /mnt/backup/appdata/
```

## Automatiser rsync
```bash
crontab -e
```
```text
00 00 * * * sudo rsync -avh -P --delete  /srv/appdata/ /mnt/backup/appdata/
```

## Dossiers de bikiniBottom

#### tv-shows

```bash
rsync -r -v --remove-source-files --progress -e ssh /home/julien/Téléchargements/torrents/tv-shows/* pleb@krabs:/mnt/data/jellystack/media/tv-shows/ && find /home/julien/Téléchargements/torrents/tv-shows/* -type d -empty -delete
```

#### movies

```bash
rsync -r -v --remove-source-files --progress -e ssh /home/julien/Téléchargements/torrents/movies/* pleb@krabs:/mnt/data/jellystack/media/movies/ && find /home/julien/Téléchargements/torrents/movies/* -type d -empty -delete
```

### target : sandy

#### ebooks (uploads)

```bash
rsync -r -v --rsync-path='sudo rsync' --remove-source-files --progress -e ssh /home/julien/Téléchargements/torrents/ebooks/* pleb@sandy:/mnt/data/docker/calibre/uploads/ && find /home/julien/Téléchargements/torrents/ebooks/* -type d -empty -delete
```

### target : bob (caddy | websites)

#### nsns.delmar.bzh

```bash
rsync -r -v --rsync-path='sudo rsync' --progress -e ssh ~/Sync/delmar.bzh/nsns/public/* -p pleb@bob:/var/www/nsns/
```

#### www.delmar.bzh

```bash
rsync -r -v --rsync-path='sudo rsync' --progress -e ssh ~/Sync/delmar.bzh/hugo/public/* -p pleb@bob:/var/www/hugo/
```

#### julien.delmar.bzh

```bash
rsync -r -v --rsync-path='sudo rsync' --progress -e ssh ~/Sync/delmar.bzh/julien/public/* -p pleb@bob:/var/www/julien/
```

#### nds.delmar.bzh

```bash
rsync -r -v --rsync-path='sudo rsync' --progress -e ssh ~/Sync/delmar.bzh/nds/public/* -p pleb@bob:/var/www/nds/
```

### Copy from &lt;folder&gt; to another &lt;host&gt;

```bash
sudo rsync -r -av --rsync-path='sudo rsync' --progress -p -e "ssh -i /home/pleb/.ssh/id_ed25519" /path/to/source/<folder> pleb@<host>:/path/to/destination/
```
