backup-solution/README.md

48 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2024-07-08 21:16:11 +00:00
# Backup Solution
This is currently WIP btw.
* Install restic > 1.14
* Create new repository (where backups are stored)
2024-09-05 14:26:31 +00:00
Create a new ssh keypair, in this example I'm naming the keyfile "keyfile"
```bash
ssh-keygen -f ~/.ssh/keyfile
```
Share the key it with the remote host
```bash
ssh-copy-id -i ~/.ssh/keyfile.pub admin@192.168.1.20
```
Create a `~/.ssh/config` file and name it. In this case we will name it "remote"
```toml
# ~/.ssh/config
Host remote
Hostname 192.168.1.20 # example
User admin
IdentityFile ~/.ssh/keyfile
```
2024-07-08 21:16:11 +00:00
```bash
# This could also be a local folder (/to/whereever/) but that's dumb.
2024-09-05 14:26:31 +00:00
export RESTIC_REPOSITORY="sftp:remote:/srv/repo"
2024-07-08 21:16:11 +00:00
restic init
# It will ask you for a password, ofc make this good and don't forget it.
```
2024-09-05 14:26:31 +00:00
Backup some files
2024-07-08 21:16:11 +00:00
```bash
2024-07-08 21:28:53 +00:00
# Set $TMPDIR to somewhere on a tmpfs filesystem to reduce drive wear
2024-07-08 21:16:11 +00:00
# Optionally add the `--tag foo` flag to tag backup snapshots
2024-07-08 21:28:53 +00:00
restic backup /ImportantDocuments --no-scan --compression max
2024-07-08 21:16:11 +00:00
```
* Restore from a snapshot:
```bash
restic snapshots
# Copy the desired snapshot id (short or long)
restic restore <id> --target <target folder>
```