Return the next item from the iterator, or None if there are no more.
- b2sdk.sync.sync.zip_folders(folder_a, folder_b, reporter, policies_manager=<b2sdk.sync.scan_policies.ScanPoliciesManager object>)
Iterate over all of the files in the union of two folders, matching file names.
Each item is a pair (file_a, file_b) with the corresponding file in both folders. Either file (but not both) will be None if the file is in only one folder.
- b2sdk.sync.sync.count_files(local_folder, reporter, policies_manager)
Count all of the files in a local folder.
local_folder (b2sdk.sync.folder.AbstractFolder) – a folder object.
reporter – reporter object
- class b2sdk.sync.sync.KeepOrDeleteMode(value)
Mode of dealing with old versions of files on the destination
- DELETE = 301
delete the old version as soon as the new one has been uploaded
- KEEP_BEFORE_DELETE = 302
keep the old versions of the file for a configurable number of days before deleting them, always keeping the newest version
- NO_DELETE = 303
keep old versions of the file, do not delete anything
- class b2sdk.sync.sync.Synchronizer(max_workers, policies_manager=<b2sdk.sync.scan_policies.ScanPoliciesManager object>, dry_run=False, allow_empty_source=False, newer_file_mode=NewerFileSyncMode.RAISE_ERROR, keep_days_or_delete=KeepOrDeleteMode.NO_DELETE, compare_version_mode=CompareVersionMode.MODTIME, compare_threshold=None, keep_days=None)
Copies multiple “files” from source to destination. Optionally deletes or hides destination files that the source does not have.
The synchronizer can copy files:
From a B2 bucket to a local destination.
From a local source to a B2 bucket.
From one B2 bucket to another.
Between different folders in the same B2 bucket. It will sync only the latest versions of files.
By default, the synchronizer:
Fails when the specified source directory doesn’t exist or is empty. (see
Fails when the source is newer. (see
Doesn’t delete a file if it’s present on the destination but not on the source. (see
Compares files based on modification time. (see
- __init__(max_workers, policies_manager=<b2sdk.sync.scan_policies.ScanPoliciesManager object>, dry_run=False, allow_empty_source=False, newer_file_mode=NewerFileSyncMode.RAISE_ERROR, keep_days_or_delete=KeepOrDeleteMode.NO_DELETE, compare_version_mode=CompareVersionMode.MODTIME, compare_threshold=None, keep_days=None)
Initialize synchronizer class and validate arguments
max_workers (int) – max number of workers
policies_manager – policies manager object
dry_run (bool) – test mode, does not actually transfer/delete when enabled
allow_empty_source (bool) – if True, do not check whether source folder is empty
newer_file_mode (b2sdk.v2.NewerFileSyncMode) – setting which determines handling for destination files newer than on the source
keep_days_or_delete (b2sdk.v2.KeepOrDeleteMode) – setting which determines if we should delete or not delete or keep for keep_days
compare_version_mode (b2sdk.v2.CompareVersionMode) – how to compare the source and destination files to find new ones
compare_threshold (int) – should be greater than 0, default is 0
keep_days (int) – if keep_days_or_delete is b2sdk.v2.KeepOrDeleteMode.KEEP_BEFORE_DELETE, then this should be greater than 0
- sync_folders(source_folder, dest_folder, now_millis, reporter, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)
Syncs two folders. Always ensures that every file in the source is also in the destination. Deletes any file versions in the destination older than history_days.
source_folder (b2sdk.sync.folder.AbstractFolder) – source folder object
dest_folder (b2sdk.sync.folder.AbstractFolder) – destination folder object
now_millis (int) – current time in milliseconds
reporter (b2sdk.sync.report.SyncReport,None) – progress reporter
encryption_settings_provider (b2sdk.v2.AbstractSyncEncryptionSettingsProvider) – encryption setting provider