Merge pull request #1016 from tcely/patch-2
Some checks are pending
CI / info (push) Waiting to run
CI / test (3.10) (push) Waiting to run
CI / test (3.11) (push) Waiting to run
CI / test (3.12) (push) Waiting to run
CI / test (3.8) (push) Waiting to run
CI / test (3.9) (push) Waiting to run
CI / containerise (push) Blocked by required conditions

Add more details about saving database entries
This commit is contained in:
meeb 2025-05-06 23:31:36 +10:00 committed by GitHub
commit dba5bc01a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,22 +18,49 @@ reset your database. If you are comfortable with Django you can export and re-im
existing database data with: existing database data with:
```bash ```bash
$ docker exec -i tubesync python3 /app/manage.py dumpdata > some-file.json $ docker exec -t tubesync \
python3 /app/manage.py \
dumpdata --format jsonl \
--exclude background_task \
--output /downloads/tubesync-database-backup.jsonl.xz
``` ```
Then change you database backend over, then use Writing the compressed backup file to your `/downloads/` makes sense, as long as that directory is still available after destroying the current container.
If you have a configuration where that file will be deleted, choose a different place to store the output (perhaps `/config/`, if it has sufficient storage available) and place the file there instead.
You can also copy the file from the container to the local filesystem (`/tmp/` in this example) with:
```bash ```bash
$ cat some-file.json | docker exec -i tubesync python3 /app/manage.py loaddata - --format=json $ docker cp \
tubesync:/downloads/tubesync-database-backup.jsonl.xz \
/tmp/
```
If you use `-` as the destination, then `docker cp` provides a `tar` archive.
After you have changed your database backend over, then use:
```bash
$ docker exec -t tubesync \
python3 /app/manage.py \
loaddata /downloads/tubesync-database-backup.jsonl.xz
```
Or, if you only have the copy in `/tmp/`, then you would use:
```bash
$ xzcat /tmp/tubesync-database-backup.jsonl.xz | \
docker exec -i tubesync \
python3 /app/manage.py \
loaddata --format=jsonl -
``` ```
As detailed in the Django documentation: As detailed in the Django documentation:
https://docs.djangoproject.com/en/3.1/ref/django-admin/#dumpdata https://docs.djangoproject.com/en/5.1/ref/django-admin/#dumpdata
and: and:
https://docs.djangoproject.com/en/3.1/ref/django-admin/#loaddata https://docs.djangoproject.com/en/5.1/ref/django-admin/#loaddata
Further instructions are beyond the scope of TubeSync documenation and you should refer Further instructions are beyond the scope of TubeSync documenation and you should refer
to Django documentation for more details. to Django documentation for more details.
@ -94,7 +121,7 @@ the DB for the performance benefits, a configuration like this would be enough:
``` ```
tubesync-db: tubesync-db:
image: postgres:15.2 image: postgres:17
container_name: tubesync-db container_name: tubesync-db
restart: unless-stopped restart: unless-stopped
volumes: volumes: