![]() |
|
[Python] Python backup script If file is already in backup folder then do nothing. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Python backup script If file is already in backup folder then do nothing. (/showthread.php?tid=5913763) |
Python backup script If file is already in backup folder then do nothing. - Dcayy - Nov 30, 2018 Hello, guys. how can I compare all files in every dir and subdirs. If any file from source dir is already in destination dir then don't backup it again just pass I have made it now just to copy and paste every file from src to dest dirs every time when scripts is started As example lets take these directories: Source directory -> /root/$USER/Desktop Destination directory -> /root/$USER/backup/Desktop RE: Python backup script If file is already in backup folder then do nothing. - Skidsuper - Nov 30, 2018 If you are checking by simple filename you can raise exception if file exists by passing os.O_EXCL in your open() funtion. See this for more info. https://stackoverflow.com/questions/30447221/copy-a-file-but-dont-overwrite-without-tocttou-issues-in-python RE: Python backup script If file is already in backup folder then do nothing. - caijad - Nov 30, 2018 (Nov 30, 2018 02:00 AM)Dcayy Wrote: Hello, guys. how can I compare all files in every dir and subdirs. Code from os import listdir,getcwd,chdir,mkdirI Hope that this work for you RE: Python backup script If file is already in backup folder then do nothing. - Lycosidae024 - Dec 1, 2018 Also, depending on how you are wanting to implement it, you can use someone similar to this which is pretty simple Code import os |