b2sdk.sync.policy
- class b2sdk.sync.policy.NewerFileSyncMode(value)[source]
Bases:
enum.Enum
Mode of handling files newer on destination than on source
- SKIP = 101
skip syncing such file
- REPLACE = 102
replace the file on the destination with the (older) file on source
- RAISE_ERROR = 103
raise a non-transient error, failing the sync operation
- class b2sdk.sync.policy.CompareVersionMode(value)[source]
Bases:
enum.Enum
Mode of comparing versions of files to determine what should be synced and what shouldn’t
- MODTIME = 201
use file modification time on source filesystem
- SIZE = 202
compare using file size
- NONE = 203
compare using file name only
- class b2sdk.sync.policy.AbstractFileSyncPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
object
Abstract policy class.
- DESTINATION_PREFIX = NotImplemented
- SOURCE_PREFIX = NotImplemented
- __init__(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
- Parameters
source_path (b2sdk.v2.AbstractSyncPath) – source file object
source_folder (b2sdk.v2.AbstractFolder) – source folder object
dest_path (b2sdk.v2.AbstractSyncPath) – destination file object
dest_folder (b2sdk.v2.AbstractFolder) – destination folder object
now_millis (int) – current time in milliseconds
keep_days (int) – days to keep before delete
newer_file_mode (b2sdk.v2.NewerFileSyncMode) – setting which determines handling for destination files newer than on the source
compare_threshold (int) – when comparing with size or time for sync
compare_version_mode (b2sdk.v2.CompareVersionMode) – how to compare source and destination files
encryption_settings_provider (b2sdk.v2.AbstractSyncEncryptionSettingsProvider) – encryption setting provider
- classmethod files_are_different(source_path: b2sdk.sync.path.AbstractSyncPath, dest_path: b2sdk.sync.path.AbstractSyncPath, compare_threshold: Optional[int] = None, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode = NewerFileSyncMode.RAISE_ERROR)[source]
Compare two files and determine if the the destination file should be replaced by the source file.
- Parameters
source_path (b2sdk.v2.AbstractSyncPath) – source file object
dest_path (b2sdk.v2.AbstractSyncPath) – destination file object
compare_threshold (int) – compare threshold when comparing by time or size
compare_version_mode (b2sdk.v2.CompareVersionMode) – source file version comparator method
newer_file_mode (b2sdk.v2.NewerFileSyncMode) – newer destination handling method
- class b2sdk.sync.policy.DownPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.AbstractFileSyncPolicy
File is synced down (from the cloud to disk).
- DESTINATION_PREFIX = 'local://'
- SOURCE_PREFIX = 'b2://'
- class b2sdk.sync.policy.UpPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.AbstractFileSyncPolicy
File is synced up (from disk the cloud).
- DESTINATION_PREFIX = 'b2://'
- SOURCE_PREFIX = 'local://'
- class b2sdk.sync.policy.UpAndDeletePolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.UpPolicy
File is synced up (from disk to the cloud) and the delete flag is SET.
- class b2sdk.sync.policy.UpAndKeepDaysPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.UpPolicy
File is synced up (from disk to the cloud) and the keepDays flag is SET.
- class b2sdk.sync.policy.DownAndDeletePolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.DownPolicy
File is synced down (from the cloud to disk) and the delete flag is SET.
- class b2sdk.sync.policy.DownAndKeepDaysPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.DownPolicy
File is synced down (from the cloud to disk) and the keepDays flag is SET.
- class b2sdk.sync.policy.CopyPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.AbstractFileSyncPolicy
File is copied (server-side).
- DESTINATION_PREFIX = 'b2://'
- SOURCE_PREFIX = 'b2://'
- class b2sdk.sync.policy.CopyAndDeletePolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.CopyPolicy
File is copied (server-side) and the delete flag is SET.
- class b2sdk.sync.policy.CopyAndKeepDaysPolicy(source_path: b2sdk.sync.path.AbstractSyncPath, source_folder: b2sdk.sync.folder.AbstractFolder, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, now_millis: int, keep_days: int, newer_file_mode: b2sdk.sync.policy.NewerFileSyncMode, compare_threshold: int, compare_version_mode: b2sdk.sync.policy.CompareVersionMode = CompareVersionMode.MODTIME, encryption_settings_provider: b2sdk.sync.encryption_provider.AbstractSyncEncryptionSettingsProvider = <b2sdk.sync.encryption_provider.ServerDefaultSyncEncryptionSettingsProvider object>)[source]
Bases:
b2sdk.sync.policy.CopyPolicy
File is copied (server-side) and the keepDays flag is SET.
- b2sdk.sync.policy.make_b2_delete_note(version, index, transferred)[source]
Create a note message for delete action.
- Parameters
version (b2sdk.v2.FileVersion) – an object which contains file version info
index (int) – file version index
transferred (bool) – if True, file has been transferred, False otherwise
- b2sdk.sync.policy.make_b2_delete_actions(source_path: b2sdk.sync.path.AbstractSyncPath, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, transferred: bool)[source]
Create the actions to delete files stored on B2, which are not present locally.
- Parameters
source_path (b2sdk.v2.AbstractSyncPath) – source file object
dest_path (b2sdk.v2.AbstractSyncPath) – destination file object
dest_folder (b2sdk.v2.AbstractFolder) – destination folder
transferred (bool) – if True, file has been transferred, False otherwise
- b2sdk.sync.policy.make_b2_keep_days_actions(source_path: b2sdk.sync.path.AbstractSyncPath, dest_path: b2sdk.sync.path.AbstractSyncPath, dest_folder: b2sdk.sync.folder.AbstractFolder, transferred: bool, keep_days: int, now_millis: int)[source]
Create the actions to hide or delete existing versions of a file stored in b2.
When keepDays is set, all files that were visible any time from keepDays ago until now must be kept. If versions were uploaded 5 days ago, 15 days ago, and 25 days ago, and the keepDays is 10, only the 25-day old version can be deleted. The 15 day-old version was visible 10 days ago.
- Parameters
source_path (b2sdk.v2.AbstractSyncPath) – source file object
dest_path (b2sdk.v2.AbstractSyncPath) – destination file object
dest_folder (b2sdk.v2.AbstractFolder) – destination folder object
transferred (bool) – if True, file has been transferred, False otherwise
keep_days (int) – how many days to keep a file
now_millis (int) – current time in milliseconds