diff --git a/PKGBUILD b/PKGBUILD index 3c8d99c..2437e87 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -8,8 +8,8 @@ url="https:/github.com/MatthiasQuintern/msynk" license=('GPL3') depends=('rsync') optdepends=('mkrypt: for encryption') -source=(msynk.sh) -md5sums=(866221e5be1842d4b0de2c9f313b06cb) +source=(msynk.sh _msynk.compdef.zsh) +md5sums=(8a25fcee8c895632f5216933b2058c68 f621c7793781a8e2684eba8c17d6a029) package() { mkdir -p "${pkgdir}/usr/bin" @@ -17,5 +17,16 @@ package() { chmod +x "${pkgdir}/usr/bin/msynk" mkdir -p "${pkgdir}/usr/share/local/man/man1/" - cp "msynk.1" "${pkgdir}/usr/share/local/man/man1/msynk.1" + cp "msynk.1.man" "${pkgdir}/usr/share/local/man/man1/msynk.1" + + mkdir -p "${pkdir}/usr/share/msynk" + cp "template" "${pkdir}/usr/share/msynk/template" + chmod +x "${pkdir}/usr/share/msynk/template" + + # if using zsh + if [[ -n $ZSH_VERSION ]]; then + mkdir -p "${pkdir}/usr/share/zsh/site-functions" + cp "${srcdir}/_msynk.compdef.zsh" "${pkdir}/usr/share/zsh/site-functions/_msynk" + chmod +x "${pkdir}/usr/share/zsh/site-functions/_msynk" + fi } diff --git a/msynk.1 b/msynk.1.man similarity index 100% rename from msynk.1 rename to msynk.1.man diff --git a/msynk.1.md b/msynk.1.md index 7586f81..2fd9d2e 100644 --- a/msynk.1.md +++ b/msynk.1.md @@ -33,7 +33,9 @@ The config files are shellscripts run with bash to set certain environent variab - sender: the parent directory of the paths\ - receiver: the path where the files should be synced to\ - rsync_flags: array containing all the flags for rsync. If you just want to add a flag, use rsync_flags+=(-yourflag)\ -- use_encryption: 0 for no, 1 for yes +- use_encryption: 0 for no, 1 for yes\ +A template config file is stored in /usr/share/msynk. +You can change the location of the configuration directory by replacing $CONFIG_DIR with your directory in /usr/bin/msynk ### Example To sync the directories "/home/user/foo" "/home/user/bar" and the file "/home/user/file.txt" to a remote server "user@foobar.com:~/backup" which is available with ssh at port 42, you could have a configuration file "my_backup":\ @@ -51,7 +53,10 @@ You can then run this with: "msynk -c my_backup"\, or if you only want to sync t : Show the current settings. **-c**, **--config** config-name -: Retrieve settings from config file ~/.config/msynk/*config-name* +: Retrieve settings from a config file in $CONFIG_DIR, eg ~/.config/msynk/*config-name* + +**--show-config** config-name +: Print variables defined from a config with *config-name*. **-s**, **--sender** path : Set sender to directory. This can also be a remote, like user@domain.com:/dir. Defaults to to the current working directory. @@ -70,12 +75,13 @@ You can then run this with: "msynk -c my_backup"\, or if you only want to sync t : Decrypt files with *mkrypt* after receiving them from the sender. Assumes that all files are encrypted and fails if that is not the case. : The files are synced to $TMP_DIR and then decrypted to the receiver directory. Does not work with --delete. -**--date** +**--check-date** : Can be used with -c and --encrypt or --decrypt: When running **msynk** with a config, the current date is stored in the config file. -: When running with --date, only files that have been modified after the date stored in the config file are processed (by passing--date [date the config was last run] to *mkrypt*). +: When running with --check-date, only files that have been modified after the date stored in the config file are processed (by passing--date [date the config was last run] to *mkrypt*). -**--mkrypt-flags** flags -: Additional flags for *mkrypt*. You can use this to set the key for the encryption. +**--mkrypt-flag** arg +: Additional argument for *mkrypt*, for example to set the key for the encryption. +: Only pass one argument at a time, so for passing two use '--mkrypt-flag "arg1" --mkrypt-flag "arg2"' **-d**, **--delete** : *rsync* --delete option. Deletes all files on the receiver that do not exist on the sender. *msynk* will open *less* with a list of all files that will be deleted and prompt you wether you want continue (unless --skip-dryrun is set) @@ -83,8 +89,9 @@ You can then run this with: "msynk -c my_backup"\, or if you only want to sync t **--skip-dryrun** : Can be used with --delete. This skips listing the files that will be deleted and the prompt. -**--rsync-flags** flags -: Additional flags for *rsync*. You can use this to set the port for the connection. +**--rsync-flag** arg +: Additional argument for *rsync*, for example to set the port for the connection. +: Only pass one argument at a time, so for passing two use '--rsync-flag "arg1" --rsync-flag "arg2"' **-v**, **--verbose** : Increase verbosity: Passes -v to rsync and mkrypt. @@ -99,6 +106,12 @@ You can then run this with: "msynk -c my_backup"\, or if you only want to sync t : If you are using a config file: pos. args. are strings that have to be contained in a path in order for it to be synced. If no pos. args. are given, all files are synced. : If you are not using a config file: pos. args. are filepaths relative to the sender directory. +# Troubleshooting +## Not enough space when using encryption +When using --encrypt, the data is encrypted to a temporary directory $TMP_DIR, when using --decrypt the encrypted date is copied to the $TMP_DIR and then decrypted. +The $TMP_DIR defaults to /tmp/mksynk and /tmp is usually limited to half the size of your memory. +You change the $TMP_DIR in the script in /usr/bin/msynk or temporarily increase the size of the tmpfs by running "sudo mount -o remount,size=XXG,noatime /tmp" if your $TMP_DIR is on /tmp and you have at least XXGB memory+swap space. + # COPYRIGHT Copyright © 2022 Matthias Quintern. License GPLv3+: GNU GPL version 3 .\ This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. diff --git a/readme.md b/readme.md index f97210a..6f1d605 100644 --- a/readme.md +++ b/readme.md @@ -16,6 +16,8 @@ The config files are shellscripts run with bash to set certain environent variab - receiver: the path where the files should be synced to - rsync_flags: array containing all the flags for rsync. If you just want to add a flag, use rsync_flags+=(-yourflag) - use_encryption: 0 for no, 1 for yes +A template config file is stored in /usr/share/msynk. +You can change the location of the configuration directory by replacing $CONFIG_DIR with your directory in /usr/bin/msynk ### Example To sync the directories "/home/user/foo" "/home/user/bar" and the file "/home/user/file.txt" to a remote server "user@foobar.com:~/backup" which is available with ssh at port 42, you could have a configuration file "my_backup": @@ -37,6 +39,9 @@ You can then run this with: `msynk -c my_backup`, or if you only want to sync th **-c**, **--config** config-name : Retrieve settings from config file ~/.config/msynk/*config-name* +**--show-config** config-name +: Print variables defined from a config with *config-name*. + **-s**, **--sender** path : Set sender to directory. This can also be a remote, like user@domain.com:/dir. Defaults to to the current working directory. @@ -54,12 +59,13 @@ You can then run this with: `msynk -c my_backup`, or if you only want to sync th : Decrypt files with *mkrypt* after receiving them from the sender. Assumes that all files are encrypted and fails if that is not the case. : The files are synced to $TMP_DIR and then decrypted to the receiver directory. Does not work with --delete. -**--date** +**--check-date** : Can be used with -c and --encrypt or --decrypt: When running **msynk** with a config, the current date is stored in the config file. -: When running with --date, only files that have been modified after the date stored in the config file are processed (by passing--date [date the config was last run] to *mkrypt*). +: When running with --check-date, only files that have been modified after the date stored in the config file are processed (by passing--date [date the config was last run] to *mkrypt*). -**--mkrypt-flags** flags -: Additional flags for *mkrypt*. You can use this to set the key for the encryption. +**--mkrypt-flag** arg +: Additional argument for *mkrypt*, for example to set the key for the encryption. +: Only pass one argument at a time, so for passing two use `--mkrypt-flag "arg1" --mkrypt-flag "arg2"` **-d**, **--delete** : *rsync* --delete option. Deletes all files on the receiver that do not exist on the sender. *msynk* will open *less* with a list of all files that will be deleted and prompt you wether you want continue (unless --skip-dryrun is set) @@ -67,8 +73,9 @@ You can then run this with: `msynk -c my_backup`, or if you only want to sync th **--skip-dryrun** : Can be used with --delete. This skips listing the files that will be deleted and the prompt. -**--rsync-flags** flags -: Additional flags for *rsync*. You can use this to set the port for the connection. +**--rsync-flag** arg +: Additional argument for *rsync*, for example to set the port for the connection. +: Only pass one argument at a time, so for passing two use `--rsync-flag "arg1" --rsync-flag "arg2"` **-v**, **--verbose** : Increase verbosity: Passes -v to rsync and mkrypt. @@ -83,6 +90,12 @@ You can then run this with: `msynk -c my_backup`, or if you only want to sync th : If you are using a config file: pos. args. are strings that have to be contained in a path in order for it to be synced. If no pos. args. are given, all files are synced. : If you are not using a config file: pos. args. are filepaths relative to the sender directory. +## Troubleshooting +### Not enough space when using encryption +When using --encrypt, the data is encrypted to a temporary directory $TMP_DIR, when using --decrypt the encrypted date is copied to the $TMP_DIR and then decrypted. +The $TMP_DIR defaults to /tmp/mksynk and /tmp is usually limited to half the size of your memory. +You change the $TMP_DIR in the script in /usr/bin/msynk or temporarily increase the size of the tmpfs by running `sudo mount -o remount,size=XXG,noatime /tmp` if your $TMP_DIR is on /tmp and you have at least XXGB memory+swap space. + ## COPYRIGHT Copyright © 2022 Matthias Quintern. License GPLv3+: GNU GPL version 3 .\ This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.