Make backup relative to the current location

34 views
Skip to first unread message

Christoph Läubrich

unread,
May 13, 2021, 2:07:09 PM5/13/21
to H2 Database
I'm writing an upgrade script and like to make a backup from withing
that script.

Is it possible to get the name of the current database location to use
for something like this:

BACKUP TO ${current-database-location}.bak


so if my current url is 'jdbc:h2:~/maydatabase' a backup is
~/maydatabase.db.bak

Noel Grandin

unread,
May 14, 2021, 5:42:41 AM5/14/21
to h2-da...@googlegroups.com


On 2021/05/13 8:07 pm, 'Christoph Läubrich' via H2 Database wrote:
> I'm writing an upgrade script and like to make a backup from withing that script.
>
> Is it possible to get the name of the current database location to use for something like this:
>

DATABASE_PATH() is the function you want:

http://h2database.com/html/functions.html#database_path



Christoph Läubrich

unread,
May 14, 2021, 9:28:54 AM5/14/21
to h2-da...@googlegroups.com
Thanks that works like a charm :-)

Am 14.05.21 um 11:42 schrieb Noel Grandin:
Reply all
Reply to author
Forward
0 new messages