diff --git a/man/simple_backup.1 b/man/simple_backup.1 index 3b7c5f6..e316258 100644 --- a/man/simple_backup.1 +++ b/man/simple_backup.1 @@ -114,6 +114,9 @@ Run rsync on the remote server with sudo. This is needed if you want to preserve .PP ALL=NOPASSWD: .RE +.TP +.B \-\-numeric\-ids +Use rsync \-\-numeric\-ids option. This causes rsync to use numeric uid/gid instead of trying to map uid/gid names from the local machine to the server .SH CONFIGURATION An example configuration file is provided at \(aq/usr/share/doc/simple_backup/simple_backup.conf\(aq. Copy it to the default location ($HOME/.config/simple_backup) and edit it as needed. diff --git a/simple_backup/simple_backup.conf b/simple_backup/simple_backup.conf index 4748976..be2a1f6 100644 --- a/simple_backup/simple_backup.conf +++ b/simple_backup/simple_backup.conf @@ -19,3 +19,4 @@ keep=-1 # username= # ssh_keyfile= # remote_sudo= +# numeric_ids= diff --git a/simple_backup/simple_backup.py b/simple_backup/simple_backup.py index 4131fd6..2db1059 100755 --- a/simple_backup/simple_backup.py +++ b/simple_backup/simple_backup.py @@ -569,6 +569,7 @@ def _parse_arguments(): choices=['a', 'l', 'p', 't', 'g', 'o', 'c', 'h', 's', 'D', 'H', 'X'], help='Specify options for rsync') parser.add_argument('--remote-sudo', action='store_true', help='Run rsync on remote server with sudo if allowed') + parser.add_argument('--numeric-ids', action='store_true', help='Use rsync \'--numeric-ids\' option (don\'t map uid/gid values by name') args = parser.parse_args() @@ -596,7 +597,7 @@ def _read_config(config_file): if not os.path.isfile(config_file): logger.warning('Config file %s does not exist', config_file) - return None, None, None, None, None, None, None, None + return None, None, None, None, None, None, None, None, None config = configparser.ConfigParser() config.read(config_file) @@ -644,7 +645,12 @@ def _read_config(config_file): except (configparser.NoSectionError, configparser.NoOptionError): remote_sudo = False - return inputs, output, exclude, keep, host, username, ssh_keyfile, remote_sudo + try: + numeric_ids = config.getboolean('server', 'numeric_ids') + except (configparser.NoSectionError, configparser.NoOptionError): + numeric_ids = False + + return inputs, output, exclude, keep, host, username, ssh_keyfile, remote_sudo, numeric_ids def _notify(text): @@ -677,7 +683,7 @@ def simple_backup(): pass try: - inputs, output, exclude, keep, host, username, ssh_keyfile, remote_sudo = _read_config(args.config) + inputs, output, exclude, keep, host, username, ssh_keyfile, remote_sudo, numeric_ids = _read_config(args.config) except (configparser.NoSectionError, configparser.NoOptionError): logger.critical('Bad configuration file') sys.exit(1) @@ -717,6 +723,9 @@ def simple_backup(): if args.compress: rsync_options.append('-z') + if numeric_ids or args.numeric_ids: + rsync_options.append('--numeric-ids') + if args.remote_sudo is not None: remote_sudo = args.remote_sudo