Repository: WeblateOrg/weblate

Issue:
Backup restore locks projects and shows no existing components
### Describe the issue

I was testing the borg backup feature in weblate and upon restoring the backup I noticed that the projects had the label that indicated that the project is locked (See Image). 

I see that the information is all there in the backup but it is not shown in the app. For example, after opening the projects, no components are found.

I have found little to no information online regarding such an issue.





### I already tried

- [X] I've read and searched [the documentation](https://docs.weblate.org/).
- [X] I've searched for similar filed issues in this repository.

### Steps to reproduce the behavior

The issue happened after following the directions for a borg backup and restore in the weblate documentation.

### Expected behavior

_No response_

### Screenshots

![Screenshot 2024-01-25 091318](https://github.com/WeblateOrg/weblate/assets/157685480/c19d28f1-b7f7-42e4-bb2d-6ec617733388)


### Exception traceback

_No response_

### How do you run Weblate?

Docker container

### Weblate versions

 weblate/weblate:edge
Hash: sha256:780310018d21eba2ef5e06b66acab7bf2e86b3ed1778640707ad47d0525cb213.

### Weblate deploy checks

_No response_

### Additional context

_No response_


Discussion:
* Maybe there were some errors shown when restoring the database? Did you follow the process?
* Were any components restored? Empty projects showed as locked until 8470b0531a5ea64387ae0c45fb5e62639407c515.
* Is there any reason for locking shown in the component history?

This issue has been marked as a question by a Weblate team member. Why? Because it belongs more to the professional [Weblate Care](https://care.weblate.org/) or community [Discussions](https://github.com/WeblateOrg/weblate/discussions) than here. We strive to answer these reasonably fast here, too, but [purchasing the support subscription](https://weblate.org/support/) is more responsible and faster for your business. And it makes Weblate stronger as well. Thanks!

In case your question is already answered, [making a donation](https://weblate.org/donate/) is the right way to say thank you!
Yes, while restoring the database there were errors regarding items that already existed or duplicate ids. 

Also, I followed the instructions in the Weblate docs. All projects were restored but no components were.


There shouldn't be any errors. And definitely you cannot expect full restore in case of errors. Can you please share log from the restoring?
Ok, I will check the k8s configuration to see if some data persisted after the restart.

I have attached the logs from the psql pod after restoring. 

[weblate-postgresql-0_postgresql.log](https://github.com/WeblateOrg/weblate/files/14055664/weblate-postgresql-0_postgresql.log)

I solved the issue by deleting the weblate database, creating a new one and then restoring it.
The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.

* In case you see a similar problem, please open a separate issue.
* If you are happy with the outcome, don’t hesitate to support Weblate by making a [donation](https://weblate.org/donate/).

Resolving patch:
diff --git a/weblate/utils/tasks.py b/weblate/utils/tasks.py
--- a/weblate/utils/tasks.py
+++ b/weblate/utils/tasks.py
@@ -102,6 +102,8 @@ def database_backup():
                 "pg_dump",
                 # Superuser only, crashes on Alibaba Cloud Database PolarDB
                 "--no-subscriptions",
+                "--clean",
+                "--if-exists",
                 "--dbname",
                 database["NAME"],
             ]


Test patch: