diff --git a/auto_database_backup/__manifest__.py b/auto_database_backup/__manifest__.py
index abbdfd723..364946fe7 100755
--- a/auto_database_backup/__manifest__.py
+++ b/auto_database_backup/__manifest__.py
@@ -22,7 +22,7 @@
{
'name': "Automatic Database Backup To Local Server, Remote Server,"
"Google Drive, Dropbox, Onedrive, Nextcloud and Amazon S3 Odoo18",
- 'version': '18.0.2.0.0',
+ 'version': '18.0.2.0.1',
'live_test_url': 'https://youtu.be/Q2yMZyYjuTI',
'category': 'Extra Tools',
'summary': 'Odoo Database Backup, Automatic Backup, Database Backup, Automatic Backup,Database auto-backup, odoo backup'
diff --git a/auto_database_backup/doc/RELEASE_NOTES.md b/auto_database_backup/doc/RELEASE_NOTES.md
index 849167966..74bf635ad 100755
--- a/auto_database_backup/doc/RELEASE_NOTES.md
+++ b/auto_database_backup/doc/RELEASE_NOTES.md
@@ -11,3 +11,9 @@
#### UPDT
- Added feature to set Multi-Level Backup Storage, Store backups in multiple locations based on different intervals.
+
+#### 13.05.2025
+#### Version 18.0.2.0.1
+#### UPDT
+
+- Updated the function that uploads the database backup to OneDrive by adding a header configurator and fixed the issue where enabling 'Remove Old Backups' would delete all backups without uploading a new one.
\ No newline at end of file
diff --git a/auto_database_backup/models/db_backup_configure.py b/auto_database_backup/models/db_backup_configure.py
index 86f515b06..9efcd1ccc 100755
--- a/auto_database_backup/models/db_backup_configure.py
+++ b/auto_database_backup/models/db_backup_configure.py
@@ -794,46 +794,86 @@ class DbBackupConfigure(models.Model):
mail_template_failed.send_mail(rec.id, force_send=True)
# Onedrive Backup
elif rec.backup_destination == 'onedrive':
- if rec.onedrive_token_validity <= fields.Datetime.now():
- rec.generate_onedrive_refresh_token()
- temp = tempfile.NamedTemporaryFile(
- suffix='.%s' % rec.backup_format)
- with open(temp.name, "wb+") as tmp:
- self.dump_data(rec.db_name, tmp, rec.backup_format, rec.backup_frequency)
- headers = {
- 'Authorization': 'Bearer %s' % rec.onedrive_access_token,
- 'Content-Type': 'application/json'}
- upload_session_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s:/%s:/createUploadSession" % (
- rec.onedrive_folder_key, backup_filename)
try:
- upload_session = requests.post(upload_session_url,
- headers=headers)
- upload_url = upload_session.json().get('uploadUrl')
- requests.put(upload_url, data=temp.read())
- if rec.auto_remove:
- list_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s/children" % rec.onedrive_folder_key
- response = requests.get(list_url, headers=headers)
- files = response.json().get('value')
- for file in files:
- create_time = file['createdDateTime'][:19].replace(
- 'T',
- ' ')
- diff_days = (
- fields.datetime.now() - fields.datetime.strptime(
- create_time, '%Y-%m-%d %H:%M:%S')).days
- if diff_days >= rec.days_to_remove:
- delete_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s" % \
- file['id']
- requests.delete(delete_url, headers=headers)
+ if rec.onedrive_token_validity <= fields.Datetime.now():
+ rec.generate_onedrive_refresh_token()
+
+ with tempfile.NamedTemporaryFile(suffix=f'.{rec.backup_format}') as temp:
+ with open(temp.name, "wb+") as tmp:
+ self.dump_data(rec.db_name, tmp, rec.backup_format, rec.backup_frequency)
+
+ headers = {
+ 'Authorization': f'Bearer {rec.onedrive_access_token}',
+ 'Content-Type': 'application/json'
+ }
+
+ upload_session_url = (
+ f"{MICROSOFT_GRAPH_END_POINT}/v1.0/me/drive/items/"
+ f"{rec.onedrive_folder_key}:/{backup_filename}:/createUploadSession"
+ )
+
+ upload_session = requests.post(upload_session_url, headers=headers)
+ upload_session.raise_for_status()
+
+ upload_url = upload_session.json().get('uploadUrl')
+ if not upload_url:
+ raise ValueError("Failed to get upload URL from OneDrive")
+
+ file_size = os.path.getsize(temp.name)
+ with open(temp.name, 'rb') as f:
+ headers_upload = {
+ 'Content-Length': str(file_size),
+ 'Content-Range': f'bytes 0-{file_size - 1}/{file_size}'
+ }
+ upload_response = requests.put(upload_url, headers=headers_upload, data=f)
+ upload_response.raise_for_status()
+
+
+ if rec.auto_remove:
+ verify_url = (
+ f"{MICROSOFT_GRAPH_END_POINT}/v1.0/me/drive/items/"
+ f"{rec.onedrive_folder_key}:/{backup_filename}"
+ )
+ verify_response = requests.get(verify_url, headers=headers)
+
+ if verify_response.status_code == 200:
+ list_url = (
+ f"{MICROSOFT_GRAPH_END_POINT}/v1.0/me/drive/items/"
+ f"{rec.onedrive_folder_key}/children"
+ )
+ response = requests.get(list_url, headers=headers)
+ response.raise_for_status()
+
+ files = response.json().get('value', [])
+ current_time = fields.datetime.now()
+
+ for file in files:
+ if file['name'] == backup_filename:
+ continue
+
+ create_time_str = file['createdDateTime'][:19].replace('T', ' ')
+ create_time = fields.datetime.strptime(create_time_str, '%Y-%m-%d %H:%M:%S')
+ diff_days = (current_time - create_time).days
+
+ if diff_days >= rec.days_to_remove:
+ delete_url = f"{MICROSOFT_GRAPH_END_POINT}/v1.0/me/drive/items/{file['id']}"
+ requests.delete(delete_url, headers=headers).raise_for_status()
+
+ # Notify user on success
+ if rec.notify_user:
+ mail_template_success.send_mail(rec.id, force_send=True)
+
+ except requests.exceptions.RequestException as req_error:
+ rec.generated_exception = str(req_error)
+ _logger.error('OneDrive API Error: %s', req_error, exc_info=True)
if rec.notify_user:
- mail_template_success.send_mail(rec.id,
- force_send=True)
+ mail_template_failed.send_mail(rec.id, force_send=True)
+
except Exception as error:
- rec.generated_exception = error
- _logger.info('Onedrive Exception: %s', error)
+ rec.generated_exception = str(error)
+ _logger.error('OneDrive Backup Error: %s', error, exc_info=True)
if rec.notify_user:
mail_template_failed.send_mail(rec.id, force_send=True)
- # NextCloud Backup
elif rec.backup_destination == 'next_cloud':
try:
if rec.domain and rec.next_cloud_password and \
diff --git a/auto_database_backup/static/description/assets/icons/ajmaljk.png b/auto_database_backup/static/description/assets/icons/ajmaljk.png
deleted file mode 100644
index e485bd8c9..000000000
Binary files a/auto_database_backup/static/description/assets/icons/ajmaljk.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup1.png b/auto_database_backup/static/description/assets/icons/auto_database_backup1.png
deleted file mode 100644
index 93faea677..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup1.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup10.png b/auto_database_backup/static/description/assets/icons/auto_database_backup10.png
deleted file mode 100644
index 7a415b0e2..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup10.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup11.png b/auto_database_backup/static/description/assets/icons/auto_database_backup11.png
deleted file mode 100644
index 12a07a449..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup11.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup12.png b/auto_database_backup/static/description/assets/icons/auto_database_backup12.png
deleted file mode 100644
index abc6a7d34..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup12.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup13.png b/auto_database_backup/static/description/assets/icons/auto_database_backup13.png
deleted file mode 100644
index 9fa13e432..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup13.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup2.png b/auto_database_backup/static/description/assets/icons/auto_database_backup2.png
deleted file mode 100644
index a8cb77759..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup2.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup3.png b/auto_database_backup/static/description/assets/icons/auto_database_backup3.png
deleted file mode 100644
index 9ef262076..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup3.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup4.png b/auto_database_backup/static/description/assets/icons/auto_database_backup4.png
deleted file mode 100644
index 82857e253..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup4.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/auto_database_backup5.png b/auto_database_backup/static/description/assets/icons/auto_database_backup5.png
deleted file mode 100644
index fc9a9e6bb..000000000
Binary files a/auto_database_backup/static/description/assets/icons/auto_database_backup5.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/blog-icon.png b/auto_database_backup/static/description/assets/icons/blog-icon.png
deleted file mode 100644
index ba4c7c366..000000000
Binary files a/auto_database_backup/static/description/assets/icons/blog-icon.png and /dev/null differ
diff --git a/auto_database_backup/static/description/assets/icons/copylink.svg b/auto_database_backup/static/description/assets/icons/copylink.svg
deleted file mode 100644
index 3b67f60e0..000000000
--- a/auto_database_backup/static/description/assets/icons/copylink.svg
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
diff --git a/auto_database_backup/static/description/assets/icons/youtube-icon.png b/auto_database_backup/static/description/assets/icons/youtube-icon.png
deleted file mode 100644
index f206560dc..000000000
Binary files a/auto_database_backup/static/description/assets/icons/youtube-icon.png and /dev/null differ
diff --git a/auto_database_backup/static/description/index.html b/auto_database_backup/static/description/index.html
index 30655d249..a79dfce9f 100644
--- a/auto_database_backup/static/description/index.html
+++ b/auto_database_backup/static/description/index.html
@@ -261,51 +261,57 @@
-
-
-
-
Read Our Detailed Blog
-pip
install dropbox
@@ -333,7 +338,126 @@
+ Generate Database Backups on regular + intervals.
++ Automatically remove old backups that + consumes storage space. +
++ Notify user on success and failure of backup + generation. +
++ Store to Remote Servers, Nextcloud, Amazon + S3, Google Drive, Dropbox, Onedrive.
++ Store backups in multiple locations based on different intervals.
+- Generate Database Backups on regular intervals to your Local Server
-- Generate Database Backups on regular intervals to your Remote Server
-- Generate Database Backups on regular intervals to Google Drive -
-- Generate Database Backups on regular intervals to Dropbox
-- Generate Database Backups on regular intervals to Onedrive
-- Generate Database Backups on regular intervals to Nextcloud
-- Generate Database Backups on regular intervals to Amazon S3
-- Notify user on success and failure of backup generation.
-- Automatically remove old backups that consumes storage space
-- You can easily set up the configuration for backup to save in multiple Locations
-