backupy icon indicating copy to clipboard operation
backupy copied to clipboard

Check .backupy path writeable before starting

Open GreenShadowMaker opened this issue 1 year ago • 0 comments

I ran backupy on a source/destination combo (that took several hours) as my user account that did not have write permissions.

Please consider adding a writable test to the key paths at the beginning, instead of after checks of all the files are run.

Thanks!

Details:

$ backupy --version
1.10.1
$ backupy -c CRC /store/photos/ /store/backup/photos/                                 
Scanning files on source:                                                                                                                   
/store/photos                                                                                                            
Scanning completed!                                                                                                                         
Scanning files on destination:                                                                                                              
/store/backup/photos                                                                                                        
Scanning completed!                                                                                                                         
Comparing directories...                                                                                                                    
Source Only (will be copied to dest): 0 (0 B)                                                                                               
Destination Only (will be archived): 0 (0 B)                                                                                                
Changed Files (archive dest and copy source -> dest): 0 (0 B)                                                                               
Moved Files (will move files on dest to match source): 0 (0 B)   
Directories already match, completed!
Traceback (most recent call last):
  File "/home/username/.local/bin/backupy", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/__init__.py", line 16, in main
    sys.exit(main())
             ~~~~^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/cli.py", line 142, in main
    return backup_manager.run()
           ~~~~~~~~~~~~~~~~~~^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/backupman.py", line 402, in run
    self.log.writeLog("database.json")
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/logman.py", line 108, in writeLog
    self.source.saveDatabase(db_name)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/filescanner.py", line 90, in saveDatabase
    writeJson(os.path.join(self.dir, self.config_dir, db_name), self.dict_current, sort_keys=True)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/lib/python3.13/site-packages/backupy/utils.py", line 78, in writeJson
    os.makedirs(os.path.dirname(file_path))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 227, in makedirs
PermissionError: [Errno 13] Permission denied: '/store/photos/.backupy'
$         

Note: username/actual paths modified

GreenShadowMaker avatar Nov 30 '24 17:11 GreenShadowMaker