# If the object to write is a directory, write all the filesįor file in object_to_backup_path.glob('**/*'):Īrcname=str(file. # If the object to write is a file, write the file ![]() Zip_file = zipfile.ZipFile(str(backup_directory_path / backup_file_name), mode='w') About Press Copyright Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features NFL Sunday Ticket Press Copyright. # Create zip file (for both file and folder options)īackup_file_name = f'backup-.zip' ![]() While len(oldest_to_newest_backup_by_name) >= MAX_BACKUP_AMOUNT: # >= because we will have another soonīackup_to_delete = oldest_to_newest_backup_by_name.pop(0) Oldest_to_newest_backup_by_name = list(sorted(existing_backups, key=lambda f: f.name)) # Enforce max backups and delete oldest if there will be too many after the new backup If x.is_file() and x.suffix = '.zip' and x.name.startswith('backup-') # Get the amount of past backup zips in the backup directory already Files inside zip folder are password encrypted: In this approach, anyone can open zip folder and unzip it. # Validate the backup directory exists and create if requiredīackup_directory_path.mkdir(parents=True, exist_ok=True) Password works in two different ways for zip file: 1. Object_to_backup_path = Path(OBJECT_TO_BACKUP)īackup_directory_path = Path(BACKUP_DIRECTORY)Īssert object_to_backup_path.exists() # Validate the object we are about to backup exists before we continue Open Windows Explorer and navigate to the folder you want to password-protect. MAX_BACKUP_AMOUNT = 5 # The maximum amount of backups to have in BACKUP_DIRECTORY ![]() OBJECT_TO_BACKUP = '/home/etre/test/' # The file or directory to backupīACKUP_DIRECTORY = '/home/etre/test-backup/' # The location to store the backups in Under the 'Encryption' section, enter a strong password or passphrase in the 'Enter passphrase' field and. From the 'Archive format' field, select zip. In the 'Archive' field, enter the name of the file or archive you want created. I use this script to make zipped backup of important folder but because after 5th backup files is moves to Recycle Bin and show to everyone I am looking for setpassword opinion to protect deleted zips or even better delete old zips but permanently (not move in Recycle Bin). Right click on the selected file (s) and/or folder (s) and click 7-Zip, and from the side tab click Add to archive.
0 Comments
Leave a Reply. |