-
-
Notifications
You must be signed in to change notification settings - Fork 90
Migration from SQLite to PostgreSQL
SQLite is the default storage backend setup in the file settings.py with the block :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.environ.get('ETESYNC_DB_PATH',
`os.path.join(BASE_DIR, 'db.sqlite3')),
}
}
As the app is based on Django, it can be used with PostgreSQL as a storage backend easily. And if you have started to store some data in EteSync, you will have to migrate your date from SQLite to PostgreSQL.
Here is how :
First make sure the server is stopped.
Just copy the SQLite database somewhere safe, juste in case :)
cp db.sqlite3 /path/to/somwhere/safe/
./manage.py dumpdata > /path/to/writable/etesync.json
You will end up with a file of several megabytes if you already have some data stored in EteSync.
You will need to setup a database to hold your data.
sudo su - postgres
createuser -P etesync # that will ask you to enter a password
createdb -O etesync
# depending on your existing configuration you might have to edit pg_hba.conf to allow the connection from etesync server
exit
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'etesync',
'USER': 'etesync',
'PASSWORD': 'etesync', # you have to put the password you chose earlier during the user creation
'HOST': '127.0.0.1', # that's if you PostgreSQL database is on the same host as your EteSync server
'PORT': '5432',
}
}
This is done with the simple command ./manage.py migrate
./manage.py loaddata /path/to/writable/etesync.json
This should end up running with no errors.
sudo su - postgres
psql
(in psql) \c etesync # or the name you have given to your database earlier
(in psql) \d # will display the tables available
(in psql) select * from auth_user; # will give you the user added to EteSync for example
./manage.py runserver 127.0.0.1:8000
if you are behind a reverse-proxy for example
- Home
- Setting up an Etebase Server (EteSync v2)
- Migration from SQLite to PostgreSQL
- Backups