change formatting
input examples are now given as ```bash input $ARG1 ``` While outputs use md's '> ' sign as a quote.
This commit is contained in:
@@ -1,26 +1,79 @@
|
||||
---
|
||||
title: "archives"
|
||||
tags: [ "Documentation", "backups" ]
|
||||
title: "Archives"
|
||||
tags: [ "Documentation", "tar", "backups" ]
|
||||
---
|
||||
# GPG Archives
|
||||
# `tar`
|
||||
|
||||
Create an encrypted archive with `gpg`:
|
||||
## Create
|
||||
|
||||
> tar czvpf - file1.txt file2.pdf file3.jpg | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz.gpg
|
||||
Combine many files and directories into a single t-archive file.
|
||||
|
||||
And extract it with `gpg`:
|
||||
```bash
|
||||
tar cf "$ARCHIVE".tar $DIR
|
||||
```
|
||||
You can remember this with the mnemonic '*C*reate *F*ile'.
|
||||
|
||||
> gpg -d myarchive.tar.gz.gpg | tar xzvf -
|
||||
Unfortunately, this stores the full file path, so making a tar archive of `/etc/nginx/` will store `etc/nginx` (without the leading `/`.
|
||||
|
||||
It's often better to tell tar which path to start from using the `-C` flag.
|
||||
|
||||
```bash
|
||||
tar cf "$ARCHIVE".tar -C /etc/ nginx
|
||||
```
|
||||
|
||||
Check the contents of your archive with:
|
||||
|
||||
```bash
|
||||
tar tf "$ARCHIVE".tar
|
||||
```
|
||||
|
||||
If you want to store 'everything in a directory', then using `*` will not work, because it will target everything in the *current* directory.
|
||||
|
||||
Instead, you can store the target in a variable:
|
||||
|
||||
```bash
|
||||
files=$(ls /etc/nginx)
|
||||
tar cf "$ARCHIVE".tar -C /etc/nginx/ $file
|
||||
```
|
||||
|
||||
## Extract
|
||||
|
||||
Extract the tar archive with
|
||||
|
||||
> tar xf "$ARCHIVE".tar
|
||||
|
||||
You can remember this with the mnemonic 'e*X*tract *F*ile'.
|
||||
|
||||
## Compress
|
||||
|
||||
Create a zip-compressed archive with the `z` flag.
|
||||
|
||||
```bash
|
||||
tar czf "$ARCHIVE".tgz -C /etc/nginx/ $file
|
||||
```
|
||||
|
||||
You can use any file ending you want, but sane people like to use '.tgz' or '.tar.tgz'.
|
||||
|
||||
# 7zip
|
||||
|
||||
(also called 'p7zip' or '7z')
|
||||
|
||||
Make archive:
|
||||
|
||||
> 7za a -tzip -pPASSWORD -mem=AES256 archive.zip file1 file2
|
||||
|
||||
```bash
|
||||
PASSWORD=my_password
|
||||
```
|
||||
```bash
|
||||
7za a -tzip -p$PASSWORD -mem=AES256 $ARCHIVE.zip $FILE_1 $FILE_2
|
||||
```
|
||||
Note that people can still see every filename in your archive, and can change those files.
|
||||
They just can't read the contents.
|
||||
|
||||
Unzip:
|
||||
|
||||
> 7za e archive.zip
|
||||
```bash
|
||||
7za x archive.zip
|
||||
```
|
||||
|
||||
7zip will open anything: zip-files, rar-files, a tin of beans, *anything*.
|
||||
However, the extracted tgz files will just be tar files, so you will still need to use tar to extract them (see above).
|
||||
|
@@ -5,28 +5,36 @@ tags: [ "Documentation", "Backups" ]
|
||||
|
||||
Install unison on both machines, and make sure both have the same version of unison, with the same version of the ocaml compiler (the smallest difference will cause problems).
|
||||
|
||||
> unison -version
|
||||
```bash
|
||||
unison -version
|
||||
```
|
||||
|
||||
Create the `~/.unison` directory on both machines.
|
||||
|
||||
Make a job called `backup`:
|
||||
|
||||
> vim ~/.unison/*backup*.prf
|
||||
|
||||
You can name the file anything, but it must end in .prf.
|
||||
|
||||
Here is an example job, which synchronizes the `~/music` directory with a remote machine.
|
||||
|
||||
```bash
|
||||
JOB=backup
|
||||
```
|
||||
|
||||
Here is an example job, which synchronizes the `~/music` directory with a remote machine which has the same username.
|
||||
|
||||
|
||||
```bash
|
||||
echo "
|
||||
auto = true
|
||||
root=/home/ghost
|
||||
root=ssh://ghost@192.168.0.10//home/ghost/
|
||||
root=$HOME
|
||||
root=ssh://$USER@$IP_ADDRESS/$HOME
|
||||
|
||||
path=music
|
||||
|
||||
ignore=Name *.flac
|
||||
" > ~/.unison/"$JOB".prf
|
||||
|
||||
```
|
||||
|
||||
Remember to specify `$IP_ADDRESS`
|
||||
|
||||
The last command means it will ignore any file with a name ending in `.flac`.
|
||||
|
||||
## Automatic Runs
|
||||
@@ -34,11 +42,12 @@ The last command means it will ignore any file with a name ending in `.flac`.
|
||||
The first command means this will run but also confirm which files will be deleted, and which will be transferred, us `batch = true` instead.
|
||||
Or you can deleted that line in the `.prf` file and run it with a flag:
|
||||
|
||||
> unison -batch *backup*.prf
|
||||
```bash
|
||||
unison -batch *backup*.prf
|
||||
```
|
||||
|
||||
Set unison to run with crontab or a systemd unit file to have directories synchronize automatically.
|
||||
|
||||
|
||||
## Problem Solving
|
||||
|
||||
You will see data files summarizing what has happened in the `~/.unison` directory.
|
||||
|
Reference in New Issue
Block a user