zertrin/duplicity-backup.sh

FilePrefixError: /etc/passwd

Zelacine opened this issue · 6 comments

Hello!

Tell me please someone.
I have customized this script. But when I test it I get the error:

duplicity-backup.sh v1.6.0
duplicity 0.7.19
----------------------------------

Traceback (innermost last):
  File "/usr/bin/duplicity", line 1581, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1567, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1406, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1154, in ProcessCommandLine
    set_selection()
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 978, in set_selection
    sel.ParseArgs(select_opts, select_files)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 250, in ParseArgs
    self.add_selection_func(self.glob_get_sf(arg, 0))
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 434, in glob_get_sf
    sel_func = self.glob_get_filename_sf(glob_str, include)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 502, in glob_get_filename_sf
    raise FilePrefixError(filename)
 FilePrefixError: /etc/passwd

Is it the reason why I don't have a backup in a certain directory?
My system:
centos-release-7-9.2009.1.el7.centos.x86_64
python2.7

Hi,

Sorry to hear you have issues.

First you should make sure that you are able to do a backup directly using duplicity (without this helper script).

Please understand that I cannot help with potential problems coming not from this script but from duplicity itself.

Once you are able to do a backup with duplicity, if you still have a problem, then please follow the troubleshooting suggestions in the README, and use debug mode to find the actual command that this script executes. Then try to run that command directly.

If this still fails, please report what the generated command is exactly. There is no way otherwise for me to understand what could be going wrong on without that information.

Hi!
First of all thanks for answering!!

I ran the command separately:

 duplicity full --exclude=/etc/passwd /etc  file:///home/admin/backup --no-encryption
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Thu Mar  4 11:13:53 2021
--------------[ Backup Statistics ]--------------
StartTime 1614875243.29 (Thu Mar  4 11:27:23 2021)
EndTime 1614875249.00 (Thu Mar  4 11:27:28 2021)
ElapsedTime 5.71 (5.71 seconds)
SourceFiles 4500
SourceFileSize 48064849 (45.8 MB)
NewFiles 4500
NewFileSize 48064849 (45.8 MB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 4500
RawDeltaSize 47900460 (45.7 MB)
TotalDestinationSizeChange 19400377 (18.5 MB)
Errors 0
-------------------------------------------------

duplicity full /var/www/html/wordpress.example.com file:///home/admin/backup --no-encryption
and on I got:

 ls /home/admin/backup/
02-03-2021  duplicity-full.20210304T161054Z.manifest         duplicity-full.20210304T161353Z.vol1.difftar.gz       logs
03-03-2021  duplicity-full.20210304T161054Z.vol1.difftar.gz  duplicity-full-signatures.20210304T161054Z.sigtar.gz
04-03-2021  duplicity-full.20210304T161353Z.manifest         duplicity-full-signatures.20210304T161353Z.sigtar.gz

I understand that there are no problems with the duplicity themselves.

Ok that's already good, but what is the exact command that this script generates? (you can get it by running the script in debug mode as suggested above)

Please try that generated command manually too, it should be able to reproduce the issue.

If it is still not working, please share what the generated command is.

Just to remind, the error you initially posted came from duplicity (File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 502, in glob_get_filename_sf).

The script itself didn't raise any error. So you should be able to reproduce the error with the generated command.

Sorry, I forgot to indicate that before that I received an error when paring via FTP.
If I understood everything correctly. I run script:

 ./duplicity-backup.sh -f -d
-------[ Program versions ]-------
duplicity-backup.sh v1.6.0
duplicity 0.7.19
----------------------------------

/usr/bin/duplicity full -v3 --no-encryption --exclude /etc/passwd --include=/var/www/html/wordpress.example.com --include=/var/www/html/drupal.example.com --include=/etc/ --include=/home/admin/backup --exclude=** /home ftp://adminftp@127.0.0.1/html/Backup
----------------[ Duplicity Cleanup ]----------------
/usr/bin/duplicity remove-all-but-n-full 4 --force --no-encryption ftp://adminftp@127.0.0.1/html/Backup

-----------[ Source Disk Use Information ]-----------
137M    /var/www/html/wordpress.example.com
137M    /var/www/html/drupal.example.com
55M     /etc/
97M     /home/admin/backup

---------[ Destination Disk Use Information ]--------
Destination disk use information is currently only available for the following storage backends:
File, SSH, Amazon S3, Google Cloud and Backblaze B2

TEST RUN ONLY: Check the logfile for command output.

and I test script:

 duplicity full -v3 --no-encryption --exclude /etc/passwd --include=/var/www/html/wordpress.example.com --include=/var/www/html/drupal.example.com --include=/etc/ --include=/home/admin/backup --exclude=** /home ftp://adminftp@127.0.0.1/html/Backup

LFTP version is 4.4.8
Password for 'adminftp@127.0.0.1':
Traceback (innermost last):
  File "/usr/bin/duplicity", line 1581, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1567, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1406, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1154, in ProcessCommandLine
    set_selection()
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 978, in set_selection
    sel.ParseArgs(select_opts, select_files)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 250, in ParseArgs
    self.add_selection_func(self.glob_get_sf(arg, 0))
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 434, in glob_get_sf
    sel_func = self.glob_get_filename_sf(glob_str, include)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 502, in glob_get_filename_sf
    raise FilePrefixError(filename)
 FilePrefixError: /etc/passwd

Two option:

duplicity full -v3 --no-encryption  --include=/var/www/html/wordpress.example.com --include=/var/www/html/drupal.example.com --include=/etc/ --include=/home/admin/backup --exclude=** /home ftp://adminftp@127.0.0.1/html/Backup

LFTP version is 4.4.8
Password for 'adminftp@127.0.0.1':
Traceback (innermost last):
  File "/usr/bin/duplicity", line 1581, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1567, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1406, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1154, in ProcessCommandLine
    set_selection()
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 978, in set_selection
    sel.ParseArgs(select_opts, select_files)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 268, in ParseArgs
    self.add_selection_func(self.glob_get_sf(arg, 1))
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 434, in glob_get_sf
    sel_func = self.glob_get_filename_sf(glob_str, include)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 502, in glob_get_filename_sf
    raise FilePrefixError(filename)
 FilePrefixError: /var/www/html/wordpress.example.com

the same happens if I just transfer to a file

 full -v3 --no-encryption --exclude=/etc/passwd --include=/var/www/html/wordpress.example.com --include=/var/www/html/drupal.example.com --include=/etc/ --include=/home/admin/backup --exclude=** /home file:///home/foobar_user_name/Backup/
bash: full: command not found
[root@localhost duplicity-backup]# duplicity full -v3 --no-encryption --exclude=/etc/passwd --include=/var/www/html/wordpress.example.com --include=/var/www/html/drupal.example.com --include=/etc/ --include=/home/admin/backup --exclude=** /home file:///home/foobar_user_name/Backup/
Traceback (innermost last):
  File "/usr/bin/duplicity", line 1581, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1567, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1406, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 1154, in ProcessCommandLine
    set_selection()
  File "/usr/lib64/python2.7/site-packages/duplicity/commandline.py", line 978, in set_selection
    sel.ParseArgs(select_opts, select_files)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 250, in ParseArgs
    self.add_selection_func(self.glob_get_sf(arg, 0))
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 434, in glob_get_sf
    sel_func = self.glob_get_filename_sf(glob_str, include)
  File "/usr/lib64/python2.7/site-packages/duplicity/selection.py", line 502, in glob_get_filename_sf
    raise FilePrefixError(filename)
 FilePrefixError: /etc/passwd

I figured out where the my error was. I changed in the config:

 The ROOT of your backup (where you want the backup to start);
# This can be / or somewhere else -- I use /home/ because all the
# directories that I want to backup start with /home/.
#
ROOT='/home'
**chachge**
ROOT="/"

And working:

Last full backup date: none
--------------[ Backup Statistics ]--------------
StartTime 1614890665.82 (Thu Mar  4 15:44:25 2021)
EndTime 1614890742.29 (Thu Mar  4 15:45:42 2021)
ElapsedTime 76.47 (1 minute 16.47 seconds)
SourceFiles 38897
SourceFileSize 383156620 (365 MB)
NewFiles 38897
NewFileSize 383156620 (365 MB)
DeletedFiles 0
ChangedFiles 0
ChangedFileSize 0 (0 bytes)
ChangedDeltaSize 0 (0 bytes)
DeltaEntries 38897
RawDeltaSize 380004255 (362 MB)
TotalDestinationSizeChange 204467291 (195 MB)
Errors 0
-------------------------------------------------

----------------[ Duplicity Cleanup ]----------------
LFTP version is 4.4.8
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Thu Mar  4 15:44:25 2021
No old backup sets found, nothing deleted.

-----------[ Source Disk Use Information ]-----------
137M    /var/www/html/wordpress.example.com
137M    /var/www/html/drupal.example.com
55M     /etc/
116M    /home/admin/backup

---------[ Destination Disk Use Information ]--------
Destination disk use information is currently only available for the following storage backends:
File, SSH, Amazon S3, Google Cloud and Backblaze B2

ls  /var/www/html/Backup/
duplicity-full.20210304T204425Z.manifest  duplicity-full.20210304T204425Z.vol1.difftar.gz  duplicity-full-signatures.20210304T204425Z.sigtar.gz

Sadly it just took a whole day.
Thanks a lot for your attention!