cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Automate backup in community edition with systemd not working

Hello,

I have a neo4j server with community edition on it. I just migrate from 4 to neo4j 5 mainly because of the use of java 17. I had a systemd timer that stopped the service and then created a backup, and then started the service again. But I have found that with neo4j 5, the services shutdowns for some reason and I can not figure it out why.

The .service script is like the following:

```

[Unit]
Description=Full backup of the database

[Service]
Type=oneshot
User=neo4j
Group=neo4j
EnvironmentFile=/etc/backup_date.env
ExecStart=/bin/neo4j stop
ExecStart=/bin/sh -c 'echo date=$(date +%%Y-%%m-%%d_%%H-%%M-%%S) > /etc/backup_date.env'
ExecStart=/bin/neo4j-admin database dump --to-path='/home/neo4j/backups' --overwrite-destination=true neo4j
ExecStart=/bin/mv /home/neo4j/backups/neo4j.dump /home/neo4j/backups/allgood_backup_${date}.dump
ExecStart=/bin/find /home/neo4j/backups/ -maxdepth 1 -type f -mtime +7 -name '*.dump' -delete
ExecStart=/bin/neo4j start

Everything runs ok, until the database shutdown by itself.

In the logs, I can only see that the server starts and the says that there is a shutdown. 

Here it is the debug.log:

2022-12-13 06:00:22.236+0000 INFO  [o.n.g.f.DatabaseManagementServiceFactory] Shutdown started
2022-12-13 06:00:22.272+0000 INFO  [o.n.b.BoltServer] Requested Bolt server shutdown
2022-12-13 06:00:22.273+0000 INFO  [o.n.b.p.c.c.ConnectionRegistry] Stopping remaining idle connections for connector bolt
2022-12-13 06:00:22.279+0000 INFO  [o.n.b.p.c.c.ConnectionRegistry] Stopped 8 idling connections for connector bolt
2022-12-13 06:00:22.290+0000 INFO  [o.n.d.d.DatabaseLifecycles] Stopping 'DatabaseId{302c9168[neo4j]}'.
2022-12-13 06:00:22.292+0000 INFO  [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/302c9168] Requirement `Database unavailable` makes database neo4j unavailable.
2022-12-13 06:00:22.293+0000 INFO  [o.n.k.a.DatabaseAvailabilityGuard] [neo4j/302c9168] DatabaseId{302c9168[neo4j]} is unavailable.
2022-12-13 06:00:22.301+0000 INFO  [o.n.k.d.Database] [neo4j/302c9168] Waiting for closing transactions.
2022-12-13 06:00:22.305+0000 INFO  [o.n.k.d.Database] [neo4j/302c9168] All transactions are closed.
2022-12-13 06:00:22.306+0000 INFO  [o.n.k.i.t.l.c.CheckPointerImpl] [neo4j/302c9168] Checkpoint triggered by "Database shutdown" @ txId: 81667 checkpoint started...
2022-12-13 06:00:22.425+0000 INFO  [o.n.k.i.t.l.c.CheckPointerImpl] [neo4j/302c9168] Checkpoint triggered by "Database shutdown" @ txId: 81667 checkpoint completed in 118ms. Checkpoint flushed 44 pages (0% of total available pages), in 42 IOs. Checkpoint performed with IO limit: unlimited, paused in total 0 times( 0 millis).
2022-12-13 06:00:22.427+0000 INFO  [o.n.k.i.t.l.p.LogPruningImpl] [neo4j/302c9168] No log version pruned. The strategy used was '5 days'. 
2022-12-13 06:00:22.513+0000 INFO  [o.n.d.d.DatabaseLifecycles] Stopped 'DatabaseId{302c9168[neo4j]}' successfully.
2022-12-13 06:00:22.513+0000 INFO  [o.n.d.d.DatabaseLifecycles] Stopping 'DatabaseId{00000000[system]}'.
2022-12-13 06:00:22.514+0000 INFO  [o.n.k.a.DatabaseAvailabilityGuard] [system/00000000] Requirement `Database unavailable` makes database system unavailable.
2022-12-13 06:00:22.514+0000 INFO  [o.n.k.a.DatabaseAvailabilityGuard] [system/00000000] DatabaseId{00000000[system]} is unavailable.
2022-12-13 06:00:22.515+0000 INFO  [o.n.k.d.Database] [system/00000000] Waiting for closing transactions.
2022-12-13 06:00:22.515+0000 INFO  [o.n.k.d.Database] [system/00000000] All transactions are closed.
2022-12-13 06:00:22.515+0000 INFO  [o.n.k.i.t.l.c.CheckPointerImpl] [system/00000000] Checkpoint triggered by "Database shutdown" @ txId: 41 checkpoint started...
2022-12-13 06:00:22.566+0000 INFO  [o.n.k.i.t.l.c.CheckPointerImpl] [system/00000000] Checkpoint triggered by "Database shutdown" @ txId: 41 checkpoint completed in 50ms. Checkpoint flushed 33 pages (0% of total available pages), in 33 IOs. Checkpoint performed with IO limit: unlimited, paused in total 0 times( 0 millis).
2022-12-13 06:00:22.567+0000 INFO  [o.n.k.i.t.l.p.LogPruningImpl] [system/00000000] No log version pruned. The strategy used was '5 days'. 
2022-12-13 06:00:22.607+0000 INFO  [o.n.d.d.DatabaseLifecycles] Stopped 'DatabaseId{00000000[system]}' successfully.
2022-12-13 06:00:22.611+0000 INFO  [o.n.b.BoltServer] Shutting down Bolt server
2022-12-13 06:00:22.611+0000 INFO  [o.n.b.p.c.c.ConnectionRegistry] Stopping 0 connections for connector bolt
2022-12-13 06:00:22.612+0000 INFO  [o.n.b.p.c.c.ConnectionRegistry] Stopped all remaining connections for connector bolt
2022-12-13 06:00:27.331+0000 INFO  [o.n.b.BoltServer] Bolt server has been shut down

 It just interesting, that I had a similar approach with neo4j 4.x.x, and it worked ok. With neo4j 5, is when the problem started.

More odd, is that If I enter to the cmd and start manually the service, starts normal and never shuts down until the next backup

0 REPLIES 0