eolas/zk/rsync.md

86 lines
1.3 KiB
Markdown
Raw Normal View History

2025-05-04 18:01:46 +01:00
---
tags: [file-transfer, Linux, procedural, disks]
created: Saturday, April 26, 2025
---
# rsync
## Ordering
### Local to local
```
SOURCE_DIR > TARGET_DIR
```
### Local to remote
```
LOCAL_SOURC_DIR > REMOTE_TARGET_DIR
```
### Remote to local
```
REMOTE_TARGET_DIR > LOCAL_SOURC_DIR
```
```sh
rsync -a <dir_to_copy_to> <dir_to_copy_from>
```
## Expanding directories
The following:
```sh
rsync -a local_dir target_dir
```
Will create `/target_dir/local_dir` at the target. In other words it will nest
the actual directory you are interested in within what you have named the
target.
To avoid this, add a slash to the source directory, viz:
```sh
rysync -a local_dir/ target_dir
```
Now, at the target, there will just be `local_dir`.
## Standard options I use
```sh
rsync -vzP
```
- verbose output
- use compression (only really useful when running rysnc over a network)
- display progress
- preserve partially copied filed and resume if network connection interrupted
## Archive mode
Use "archive mode" when specifically wanting to create a backup of a directory
(i.e. for long term storage rather than immediate use).
```sh
rsync -a
```
Archive mode is an umbrella for the following flags:
- `-r`: recursive
- `l`: copy [symlinks](./Symlinks.md) as symlinks
- `p`: preserve permissions
- `t`: preserve times
- `g`: preserve group