-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dropbox docs missing required settings #480
Comments
"Dropbox has recently introduced short-lived access tokens only, and does not seem to allow new apps to generate access tokens that do not expire." django-dbbackup does not use correct settings for Dropbox. |
Indeed this still seems to be not fixed in docs. I confirm it worked for me with added |
I used this script import os
import sqlite3
import sys
import tarfile
def database_backup(from_path, to_path):
"""
Backup database from one path to another.
"""
def progress(status, remaining, total):
print(f"Copied {total - remaining} of {total} pages...")
src = sqlite3.connect(from_path)
dst = sqlite3.connect(to_path)
with dst:
src.backup(dst, pages=1, progress=None)
dst.close()
src.close()
print(f"Database backup from {from_path} to {to_path} completed.")
def media_backup(from_path, to_path):
"""
Backup media from one path to another.
"""
tar = tarfile.open(to_path, "w:gz")
tar.add(from_path)
tar.close()
print(f"Media backup from {from_path} to {to_path} completed.")
if __name__ == "__main__":
print(f"Running backup.py with args: {sys.argv} from dir: {os.getcwd()}")
cmd = sys.argv[1]
match cmd:
case "database":
database_backup(sys.argv[2], sys.argv[3])
case "media":
media_backup(sys.argv[2], sys.argv[3]) #!/bin/bash
set -e
get_db_path() {
./manage.py shell -c 'from django.conf import settings; print(settings.DATABASES["default"]["NAME"])'
}
get_media_path() {
./manage.py shell -c 'from django.conf import settings; print(settings.MEDIA_ROOT)'
}
backup() {
backup_dir="$(pwd)/data/backups"
database_path=$(get_db_path)
media_dir=$(get_media_path)
database_backup_path="${backup_dir}/$GIT_BUILD_ID-$(date +%Y-%m-%d-%H-%M-%S)-db.sqlite3"
echo "Database exists, backing up from ${database_path} to ${database_backup_path}"
python ./backup.py database "${database_path}" "${database_backup_path}"
media_backup_path="${backup_dir}/$GIT_BUILD_ID-$(date +%Y-%m-%d-%H-%M-%S)-media.tar.gz"
echo "Backing up media from ${media_dir} to ${media_backup_path}"
python ./backup.py media "${media_dir}" "${media_backup_path}"
}
if [ "$1" == "backup" ]; then
backup
exit 0
fi
# check if database exists
if [ -f $database_path ]; then
backup
fi
python manage.py collectstatic --no-input --clear
python manage.py migrate
exec gunicorn -c python:conf.gunicorn |
Is there any way the django-dbbackup could handle this and refreshing the tokens? |
Describe the bug
Dropbox docs are missleading.
To Reproduce
pip install dropbox django-storages
.oauth2_access_token
:dropbox.dropbox_client.BadInputException: OAuth2 access token or refresh token or app key/secret must be set
Read source code https://github.com/jschneier/django-storages/blob/7914409c90f04a749e517bb39635b218d908265f/storages/backends/dropbox.py#L86
Set:
The text was updated successfully, but these errors were encountered: