Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: How to backup akonadi database?

  1. #1

    Question How to backup akonadi database?

    I am currently setting up a tape backup.

    Looking at the user's home directory I see there are lots of files in ~/.local/share/akonadi/db_data/. Considering that it is a live database I suppose it would be highly incorrect to simply copy the files and I should rather make a database dump. On the other hand being logged in as root in mysql and running 'show databases;' does not show a database for akonadi at all which means I can't even find a way to dump the database to an .sql file.

    The next (maybe not the wisest) idea which came to my mind: maybe I could run a before-backup script which stops the service, then run the backup, then restart the service. However I don't even find a service named akonadi in YaST.

    So what is the proper way to do this?

  2. #2
    Join Date
    Jun 2008
    Location
    Belleville, Ontario, Canada
    Posts
    472

    Default Re: How to backup akonadi database?

    Maybe it's using sqlite and not mysql?
    "Making rich people richer doesn't make the rest of us richer." Ha-Joon Chang
    openSUSE 15.1 4.12.14-lp151.28.16-default x64

  3. #3

    Default Re: How to backup akonadi database?

    Quote Originally Posted by kerijan2003 View Post
    Maybe it's using sqlite and not mysql?
    After reading this I don't think so. And sqlite db's use a single file AFAIK which doesn't seem to be the case here.

  4. #4

    Default Re: How to backup akonadi database?

    Quote Originally Posted by heyjoe View Post
    Looking at the user's home directory I see there are lots of files in ~/.local/share/akonadi/db_data/. Considering that it is a live database I suppose it would be highly incorrect to simply copy the files and I should rather make a database dump. On the other hand being logged in as root in mysql and running 'show databases;' does not show a database for akonadi at all which means I can't even find a way to dump the database to an .sql file.
    Akonadi uses an internal MySQL instance by default, unless you explicitely configure it to use an external/system-wide MySQL server.

    You can run mysql and tell it to connect to a running akonadi server though:
    Code:
    mysql --socket=$HOME/.local/share/akonadi/instance/$1/socket-`hostname`/mysql.socket akonadi
    See https://quickgit.kde.org/?p=akonadi....ysql-client.sh

    The next (maybe not the wisest) idea which came to my mind: maybe I could run a before-backup script which stops the service, then run the backup, then restart the service. However I don't even find a service named akonadi in YaST.
    It runs as user and is no system service.
    Use "akonadictl stop" to stop it.

    Another option: run akonaditray, right-click on the tray icon (it's hidden normally so click on the up arrow in the tray) and choose "Make Backup...".

    But, as the Akonadi database is just a cache, it isn't really necessary to back it up. Although some things can get confused when the database is lost, e.g. filters only store the database id for destination folders.

  5. #5

    Default Re: How to backup akonadi database?

    Thanks for the info wolfi!

    Quote Originally Posted by wolfi323 View Post
    You can run mysql and tell it to connect to a running akonadi server though:
    Code:
    mysql --socket=$HOME/.local/share/akonadi/instance/$1/socket-`hostname`/mysql.socket akonadi
    How can I use this to make a mysqldump of the database?

    It runs as user and is no system service.
    Use "akonadictl stop" to stop it.
    Yes, I found that info in the meantime. But is it good to stop it and restart it after backup completion (i.e. copy all separate files). Isn't the right approach with DBs to dump them to a single file and copy that one?

    Another option: run akonaditray, right-click on the tray icon (it's hidden normally so click on the up arrow in the tray) and choose "Make Backup...".
    Unfortunately that is not an option as I am trying to automate the backup process.

    But, as the Akonadi database is just a cache, it isn't really necessary to back it up. Although some things can get confused when the database is lost, e.g. filters only store the database id for destination folders.
    I didn't know it was a cache but considering your further clarification I guess then it is better to have a backup after all?

  6. #6

    Default Re: How to backup akonadi database?

    Quote Originally Posted by heyjoe View Post
    How can I use this to make a mysqldump of the database?
    Actually it should be this, sorry:
    Code:
    mysql --socket=$HOME/.local/share/akonadi/socket-`hostname`/mysql.socket akonadi
    (the "instance" part allows to run several Akonadi-Servers in parallel, but that's normally not used.

    And mysqldump accepts the same "--socket" parameter, so this should create a dump of the Akonadi database:
    Code:
    mysql --socket=$HOME/.local/share/akonadi/socket-`hostname`/mysql.socket akonadi
    (replace $HOME accordingly, if you run this as different user)

    Yes, I found that info in the meantime. But is it good to stop it and restart it after backup completion (i.e. copy all separate files). Isn't the right approach with DBs to dump them to a single file and copy that one?
    Yes. But you can just as well backup the actual database files. You just need to make sure the file permissions/ownership is ok afterwards (and mysql/akonadi shouldn't be running when you restore the backup...)

    I didn't know it was a cache but considering your further clarification I guess then it is better to have a backup after all?
    As I said, it is not really necessary (especially if you don't use KMail), it doesn't contain any data normally.
    But, some data can temporarily exist in the cache only, until it is synchronized with the actual storage.

    So yes, it's probably better to back it up. If there are problems after restoring the backup, you can still delete the database...

  7. #7

    Default Re: How to backup akonadi database?

    Thanks. BTW this is also not the correct path. Actually the socket-`hostname` is a link to /tmp/akonadi-myusername.jlR8VV which does not exist at all. I tried to use the correct path to mysql.conf but then:

    Code:
    # mysql --socket=$HOME/.local/share/akonadi/mysql.conf akonadi
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/home/myusername/.local/share/akonadi/mysql.conf' (111 "Connection refused")
    Have we found a bug?

  8. #8

    Default Re: How to backup akonadi database?

    Quote Originally Posted by heyjoe View Post
    Thanks. BTW this is also not the correct path. Actually the socket-`hostname` is a link to /tmp/akonadi-myusername.jlR8VV which does not exist at all.
    Akonadi has to be running for the socket to exist.
    And you should really use $HOME/.local/share/akonadi/instance/$1/socket-`hostname`, the actual folder in /tmp can and will change.

    I tried to use the correct path to mysql.conf but then:
    ...
    Have we found a bug?
    No, your command is wrong.
    mysql.conf is the mysql *config file*, not a socket.
    You cannot connect to that...

  9. #9

    Default Re: How to backup akonadi database?

    Quote Originally Posted by wolfi323 View Post
    Akonadi has to be running for the socket to exist.
    And you should really use $HOME/.local/share/akonadi/instance/$1/socket-`hostname`, the actual folder in /tmp can and will change.
    Ok, I see. 'akonadictl status' was showing that it was not running. When I start it manually I can do a mysqldump as you explained.

    So as I read here and here it seems that service is running only if certain apps use it. Right?

    In that case - to make a mysqldump correctly, should I include in my script commands to:

    1. start akonadi (if not running)
    2. mysqldump its db to a file.sql
    3. stop akonadi (if it was not running before 1)
    4. backup the file.sql
    5. optionally delete file.sql

    If that is a correct algorithm, that raises the question: how would the script start and stop the akonadi service? The script is running as user 'bareos' and the service obviously needs to be started as each individual human user. How would that be accomplished?

    Or am I overthinking it?

  10. #10

    Default Re: How to backup akonadi database?

    Quote Originally Posted by heyjoe View Post
    So as I read here and here it seems that service is running only if certain apps use it. Right?
    Right. It is only started if an application needs it, but then it keeps running until you stop it manually.

    If that is a correct algorithm, that raises the question: how would the script start and stop the akonadi service? The script is running as user 'bareos' and the service obviously needs to be started as each individual human user. How would that be accomplished?

    Or am I overthinking it?
    IMHO yes. I would just backup the files, if anything. After all it's only a cache...

    Another option would be to use an external/system-wide mysql server for Akonadi (like I do), you will then backup the Akonadi database(s) together with the other databases anyway.

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •