Re: Doubts about online backups using freeze / unfreeze

2023-08-08 Thread Rick Hillegas
I never use the freeze and unfreeze commands but your understanding of 
them sounds correct and is consistent with the following ij experiment:


ij version 10.17

ij> CONNECT 'jdbc:derby:zdb;create=true';

ij> CREATE TABLE t(a INT);

0 rows inserted/updated/deleted

ij> INSERT INTO t VALUES (1);

1 row inserted/updated/deleted

ij> CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE();

0 rows inserted/updated/deleted

ij> SELECT * FROM t;

A

---

1

1 row selected

ij> DISCONNECT;

ij> CONNECT 'jdbc:derby:zdb';

ij> SELECT * FROM t;

A

---

1

1 row selected

ij> CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE();

0 rows inserted/updated/deleted

ij> INSERT INTO t VALUES (2);

1 row inserted/updated/deleted

ij> SELECT * FROM t;

A

---

1

2

2 rows selected

Hope this helps,
-Rick

On 8/7/23 2:55 PM, fed wrote:

Hi,

I have a derby network server running with some databases connected and I
want to backup the databases directory with my backup utility.
My idea is to connect to every database in the network server and call the
freeze procedure, execute the backup of the databases directories and then
call the unfreeze procedure on every db, but I have some doubts.

Q1:
I am going for every database to get a connection, execute

CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()

and then close the connection. After this I execute the backup with my
backup utility and then later after the backup is finished for every
database get a new connection and execute:

CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()   , is this correct?

>From the example in the documentation it seems that I have to use the same
connection to call the two stored procedures, but this is not required,
right?

public static void backUpDatabaseWithFreeze(Connection conn)
throws SQLException {
 Statement s = conn.createStatement();
 s.executeUpdate(
 "CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()");
 *//copy the database directory during this interval*
 s.executeUpdate(
 "CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()");
 s.close();
}


Q2:
If I stop the network server while the database is in "freeze" state when I
restart it, it is still in "freeze" state and I have to call unfreeze on it?
My concern is that It is not possible that I get stuck in the "freeze"
state of the database, I can always "unfreeze" it, right?

Q3:
Last question, sorry for lots of questions: just to confirm even if in a
freeze state I can acquire a connection and execute a read operation
(select) on the database even in a transaction, right?

Thanks for the help
- fed



Re: Doubts about online backups using freeze / unfreeze

2023-08-08 Thread Oscar Melendez
:02

El lun., 7 de agosto de 2023 4:56 p. m., fed  escribió:

> Hi,
>
> I have a derby network server running with some databases connected and I
> want to backup the databases directory with my backup utility.
> My idea is to connect to every database in the network server and call the
> freeze procedure, execute the backup of the databases directories and then
> call the unfreeze procedure on every db, but I have some doubts.
>
> Q1:
> I am going for every database to get a connection, execute
>
> CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()
>
> and then close the connection. After this I execute the backup with my
> backup utility and then later after the backup is finished for every
> database get a new connection and execute:
>
> CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()   , is this correct?
>
> From the example in the documentation it seems that I have to use the same
> connection to call the two stored procedures, but this is not required,
> right?
>
> public static void backUpDatabaseWithFreeze(Connection conn)
>   throws SQLException {
> Statement s = conn.createStatement();
> s.executeUpdate(
> "CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()");
> *//copy the database directory during this interval*
> s.executeUpdate(
> "CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()");
> s.close();
> }
>
>
> Q2:
> If I stop the network server while the database is in "freeze" state when
> I restart it, it is still in "freeze" state and I have to call unfreeze on
> it?
> My concern is that It is not possible that I get stuck in the "freeze"
> state of the database, I can always "unfreeze" it, right?
>
> Q3:
> Last question, sorry for lots of questions: just to confirm even if in a
> freeze state I can acquire a connection and execute a read operation
> (select) on the database even in a transaction, right?
>
> Thanks for the help
> - fed
>
>
>
>
>