Return the next item from the iterator, or None if there are no more.
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.
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
Mode of dealing with old versions of files on the destination
delete the old version as soon as the new one has been uploaded
keep the old versions of the file for a configurable number of days before deleting them, always keeping the newest version
keep old versions of the file, do not delete anything
Synchronizer(max_workers, policies_manager=<b2sdk.sync.scan_policies.ScanPoliciesManager object>, dry_run=False, allow_empty_source=False, newer_file_mode=<NewerFileSyncMode.RAISE_ERROR: 103>, keep_days_or_delete=<KeepOrDeleteMode.NO_DELETE: 303>, compare_version_mode=<CompareVersionMode.MODTIME: 201>, 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: 103>, keep_days_or_delete=<KeepOrDeleteMode.NO_DELETE: 303>, compare_version_mode=<CompareVersionMode.MODTIME: 201>, 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.v1.NewerFileSyncMode) – setting which determines handling for destination files newer than on the source
keep_days_or_delete (b2sdk.v1.KeepOrDeleteMode) – setting which determines if we should delete or not delete or keep for keep_days
compare_version_mode (b2sdk.v1.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.v1.KeepOrDeleteMode.KEEP_BEFORE_DELETE, then this should be greater than 0
sync_folders(source_folder, dest_folder, now_millis, reporter)¶
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.
make_folder_sync_actions(source_folder, dest_folder, now_millis, reporter, policies_manager=<b2sdk.sync.scan_policies.ScanPoliciesManager object>)¶
Yield a sequence of actions that will sync the destination folder to the source folder.
make_file_sync_actions(sync_type, source_file, dest_file, source_folder, dest_folder, now_millis)¶
Yields the sequence of actions needed to sync the two files
sync_type (str) – synchronization type
source_file (b2sdk.v1.File) – source file object
dest_file (b2sdk.v1.File) – destination file object
source_folder (b2sdk.v1.AbstractFolder) – a source folder object
dest_folder (b2sdk.v1.AbstractFolder) – a destination folder object
now_millis (int) – current time in milliseconds