Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Eraiyanbupeterfrancis/AutoBackupTool/llms.txt
Use this file to discover all available pages before exploring further.
backup_utils.py is the core module that handles all backup and restore logic in AutoBackupTool. It provides functions for compressing and encrypting folders, uploading to Google Drive, logging backup history, listing available backups, and restoring files.
The module reads two configuration values from backup.env at import time:
backup_utils.py
Functions
get_drive_instance
GoogleDrive instance. Loads the OAuth client config from CLIENT_SECRETS_FILE and cached credentials from mycreds.txt. If no credentials exist, opens a browser for OAuth authorization. If the access token is expired, it is refreshed automatically. Credentials are saved to mycreds.txt after any change.
backup_utils.py
compress_and_encrypt_folder
Absolute or relative path to the folder to back up. All files are included recursively. File paths inside the zip are relative to the parent of
folder_path.BytesIO object containing the Fernet-encrypted zip data, ready to pass to upload_to_drive_stream.
backup_utils.py
upload_to_drive_stream
The encrypted data to upload, as returned by
compress_and_encrypt_folder.The Drive file title. The GUI uses the format
backup_YYYYMMDD_HHMMSS.enc.alternateLink (shareable URL) for the uploaded file. After each upload, queries Drive for all files with backup_ in the title and deletes the oldest (by createdDate) if more than five exist.
log_backup
backup_log.json in the current working directory.
The backup filename as uploaded to Drive.
The Google Drive
alternateLink returned by upload_to_drive_stream.backup_log.json gracefully by starting with an empty list.
list_backups
(title, file_id) tuples. Queries Drive for files with backup_ in the title. Used by the GUI to populate the restore dialog.
restore_backup
The Google Drive file ID of the backup to restore.
Local directory path where files will be extracted.
Optional callback function. Called with
50 after the file is downloaded and with 100 after extraction completes. Used by the GUI to update the progress bar.decrypt_and_extract
The raw encrypted bytes downloaded from Google Drive.
Local directory path to extract the decrypted files into.
backup_utils.py
You must use the same
ENCRYPTION_KEY that was used when the backup was created. A different key will cause fernet.decrypt to raise an InvalidToken error.