Added --exclude

This commit is contained in:
matthias@arch 2022-04-08 01:56:55 +02:00
parent 20eb5a23c9
commit b6cb6db4d3
6 changed files with 39 additions and 12 deletions

View File

@ -1,6 +1,6 @@
# Maintainer: Matthias Quintern <matthiasqui@protonmail.com> # Maintainer: Matthias Quintern <matthiasqui@protonmail.com>
pkgname=msynk pkgname=msynk
pkgver=1.0 pkgver=1.1
pkgrel=1 pkgrel=1
pkgdesc="rsync helper that supports encryption and presets" pkgdesc="rsync helper that supports encryption and presets"
arch=('any') arch=('any')

View File

@ -32,6 +32,7 @@ _msynk()
{--verbose,-v}'[Increase verbosity.]' \ {--verbose,-v}'[Increase verbosity.]' \
'--silent[Decrease verbosity.]' \ '--silent[Decrease verbosity.]' \
'--debug[Maximum verbosity.]' \ '--debug[Maximum verbosity.]' \
'--exclude[Interpret positional arguments as blacklist]' \
'*:file or directory:_files' '*:file or directory:_files'
} }
_msynk "$@" _msynk "$@"

View File

@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 2.14.2 .\" Automatically generated by Pandoc 2.17.0.1
.\" .\"
.TH "MSYNK" "1" "March 2022" "msynk 1.0" "" .TH "MSYNK" "1" "March 2022" "msynk 1.1" ""
.hy .hy
.SH NAME .SH NAME
.PP .PP
@ -11,7 +11,8 @@ Local:
.PD 0 .PD 0
.P .P
.PD .PD
\ \ \ \f[B]msynk\f[R] [OPTION\&...] -r DEST_DIR -s SOURCE_DIR PATHS\&... \ \ \ \f[B]msynk\f[R] [OPTION\&...]
-r DEST_DIR -s SOURCE_DIR PATHS\&...
.PP .PP
Via remote shell: Via remote shell:
.PD 0 .PD 0
@ -21,8 +22,8 @@ Via remote shell:
.PD 0 .PD 0
.P .P
.PD .PD
\ \ \ \ \ \ \ \ \f[B]msynk\f[R] [OPTION\&...] -r \ \ \ \ \ \ \ \ \f[B]msynk\f[R] [OPTION\&...]
[USER\[at]]HOST:DEST_DIR -s SOURCE_DIR PATHS\&... -r [USER\[at]]HOST:DEST_DIR -s SOURCE_DIR PATHS\&...
.PD 0 .PD 0
.P .P
.PD .PD
@ -30,14 +31,15 @@ Via remote shell:
.PD 0 .PD 0
.P .P
.PD .PD
\ \ \ \ \ \ \ \ \f[B]msynk\f[R] [OPTION\&...] -r DEST_DIR -s \ \ \ \ \ \ \ \ \f[B]msynk\f[R] [OPTION\&...]
[USER\[at]]HOST:SOURCE_DIR PATHS\&... -r DEST_DIR -s [USER\[at]]HOST:SOURCE_DIR PATHS\&...
.PP .PP
Using a configuration file: Using a configuration file:
.PD 0 .PD 0
.P .P
.PD .PD
\ \ \ \ \f[B]msynk\f[R] [OPTION\&...] -c CONFIG NAME [SELECTIONS\&...] \ \ \ \ \f[B]msynk\f[R] [OPTION\&...]
-c CONFIG NAME [SELECTIONS\&...]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]msynk\f[R] uses \f[I]rsync\f[R] to synchronise files or directories \f[B]msynk\f[R] uses \f[I]rsync\f[R] to synchronise files or directories
@ -197,6 +199,9 @@ mkrypt.
\f[B]\[em]-debug\f[R] \f[B]\[em]-debug\f[R]
Maximum verbosity: -v but also print out rsync and mkrypt commands. Maximum verbosity: -v but also print out rsync and mkrypt commands.
.TP .TP
\f[B]\[em]-exclude\f[R]
Interpret positional arguments as blacklist, not whitelist.
.TP
\f[B]positional arguments\f[R] \f[B]positional arguments\f[R]
If you are using a config file: pos. If you are using a config file: pos.
args. args.

View File

@ -1,4 +1,4 @@
% MSYNK(1) msynk 1.0 % MSYNK(1) msynk 1.1
% Matthias Quintern % Matthias Quintern
% March 2022 % March 2022
@ -102,6 +102,9 @@ You can then run this with: "msynk -c my_backup"\, or if you only want to sync t
**--debug** **--debug**
: Maximum verbosity: -v but also print out rsync and mkrypt commands. : Maximum verbosity: -v but also print out rsync and mkrypt commands.
**--exclude**
: Interpret positional arguments as blacklist, not whitelist.
**positional arguments** **positional arguments**
: 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 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. : If you are not using a config file: pos. args. are filepaths relative to the sender directory.

View File

@ -55,10 +55,18 @@ check_path_in_args()
fi fi
for string in ${paths_2[@]}; do for string in ${paths_2[@]}; do
if [[ $path == *$string* ]]; then if [[ $path == *$string* ]]; then
return 0 if [[ $exclude = 1 ]]; then
return 1
else
return 0
fi
fi fi
done done
return 1 if [[ $exclude = 1 ]]; then
return 0
else
return 1
fi
} }
@ -181,6 +189,8 @@ show_help()
--silent Decrease verbosity. --silent Decrease verbosity.
--debug Maximum verbosity. --debug Maximum verbosity.
--exclude Interpret positional arguments as blacklist
Positional arguments are: Positional arguments are:
- if using a config: a string that must be in the configs paths: eg. 'foo' will include ~/foo but not ~/bar - if using a config: a string that must be in the configs paths: eg. 'foo' will include ~/foo but not ~/bar
- if not using a config: paths to sync (must be relative to --sender) - if not using a config: paths to sync (must be relative to --sender)
@ -295,6 +305,9 @@ while (( "$#" )); do
rsync_flags+=(-v) rsync_flags+=(-v)
mkrypt_flags+=(-v) mkrypt_flags+=(-v)
shift;; shift;;
--exclude)
exclude=1
shift ;;
-*|--*=) # unsupported flags -*|--*=) # unsupported flags
printf "$FMT_ERROR" "Unsupported flag $1" >&2 printf "$FMT_ERROR" "Unsupported flag $1" >&2
exit 1 ;; exit 1 ;;

View File

@ -47,6 +47,7 @@ You can then run this with: `msynk -c my_backup`, or if you only want to sync th
- `-v, --verbose` Increase verbosity: Passes -v to rsync and mkrypt. - `-v, --verbose` Increase verbosity: Passes -v to rsync and mkrypt.
- `--silent` Decrease verbosity: Print only error messages and passes --silent to mkrypt. - `--silent` Decrease verbosity: Print only error messages and passes --silent to mkrypt.
- `--debug` Maximum verbosity: -v but also print out rsync and mkrypt commands. - `--debug` Maximum verbosity: -v but also print out rsync and mkrypt commands.
- `--exclude` Interpret positional arguments as blacklist, not as whitelist.
- `positional arguments` 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. - `positional arguments` 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 ## Troubleshooting
@ -55,6 +56,10 @@ When using --encrypt, the data is encrypted to a temporary directory $TMP_DIR, w
The $TMP_DIR defaults to /tmp/mksynk and /tmp is usually limited to half the size of your memory. 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. 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.
## Changelog
### 1.1
- Added --exclude
## COPYRIGHT ## COPYRIGHT
Copyright © 2022 Matthias Quintern. License GPLv3+: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.\ Copyright © 2022 Matthias Quintern. License GPLv3+: GNU GPL version 3 <https://gnu.org/licenses/gpl.html>.\
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.