Skip to content

Commit 2b47332

Browse files
NataliaIvakinanick-giles-neoFrannie-Ludmillarenetapopova
authored
Explain the use of prefer-diff-as-parent (#2286)
Co-authored-by: Nick Giles <[email protected]> Co-authored-by: Frannie-Ludmilla <[email protected]> Co-authored-by: Reneta Popova <[email protected]>
1 parent a5e75a1 commit 2b47332

File tree

1 file changed

+152
-1
lines changed

1 file changed

+152
-1
lines changed

modules/ROOT/pages/backup-restore/online-backup.adoc

+152-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Note: this is an EXPERIMENTAL option. Consult Neo4j support before use.
161161
|false
162162

163163
|--prefer-diff-as-parent
164-
|label:new[Introduced in 2025.04] When performing a differential backup, prefer the latest non-empty differential backup as the parent instead of the latest full backup.
164+
|label:new[Introduced in 2025.04] When performing a differential backup, prefer the latest non-empty differential backup as the parent instead of the latest backup.
165165
|false
166166

167167
|--temp-path=<path>
@@ -459,3 +459,154 @@ bin/neo4j-admin database backup --to-path=azb://myStorageAccount/myContainer/myD
459459
----
460460
======
461461
=====
462+
463+
464+
[role=label--new-2025.04]
465+
[[diff-backup-as-parent]]
466+
=== Perform a differential backup using the `--prefer-diff-as-parent` option
467+
468+
By default, a differential backup (`--type=DIFF`) uses the *most recent non-empty* backup -- whether full or differential -- in the directory as its parent.
469+
470+
The `--prefer-diff-as-parent` option changes this behavior and forces the backup job to use the *latest differential* backup as the parent, even if a newer full backup exists.
471+
472+
This approach allows you to maintain a chain of differential backups for all transactions and restore to any point in time.
473+
Without this option, the transactions between the last full backup and a previous differential backup cannot be backed up as individual transactions.
474+
475+
To use the `--prefer-diff-as-parent` option, set it to `true`.
476+
477+
The following examples cover different scenarios for using the `--prefer-diff-as-parent` option.
478+
479+
[.tabbed-example]
480+
=====
481+
[role=include-with-Chain-with-full-and-differential-backups]
482+
======
483+
484+
Let's assume that you write 10 transactions to the `neo4j` database every hour, except from 12:30 to 13:30, when you do not write any transactions.
485+
486+
There is a backup job that takes a backup every hour and a full backup every four hours.
487+
An empty backup has no transactions, meaning that both the lower transaction ID and the upper transaction ID are zero.
488+
489+
Imagine you have the following backup chain:
490+
491+
[cols="h,e,m,h,h"]
492+
|===
493+
|Timestamp | Backup name | Backup type | Lower Transaction ID | Upper Transaction ID
494+
495+
| 10:30
496+
| backup1
497+
| FULL
498+
| 1
499+
| 10
500+
501+
| 11:30
502+
| backup2
503+
| DIFF
504+
| 11
505+
| 20
506+
507+
| 12:30
508+
| backup3
509+
| DIFF
510+
| 21
511+
| 30
512+
513+
| 13:30
514+
| backup4
515+
| DIFF
516+
| 0
517+
| 0
518+
519+
| 14:30
520+
| backup5
521+
| FULL
522+
| 1
523+
| 40
524+
525+
|===
526+
527+
At 15:30, you execute the following backup command:
528+
529+
[source,shell]
530+
----
531+
neo4j-admin database backup --from=<address:port> --to-path=<targetPath> --type=DIFF neo4j
532+
----
533+
534+
The result would be:
535+
536+
[cols="h,e,m,h,h"]
537+
|===
538+
| 15:30
539+
| backup6
540+
| DIFF
541+
| 41
542+
| 50
543+
|===
544+
545+
The result means you have chosen `backup5` as the parent for your differential `backup6` since the `backup5` is the *latest non-empty* backup.
546+
547+
However, if you execute the following command with the `--prefer-diff-as-parent` option:
548+
549+
[source,shell]
550+
----
551+
neo4j-admin database backup --from=<address:port> --to-path=<targetPath> --type=DIFF --prefer-diff-as-parent neo4j
552+
----
553+
554+
The result would be:
555+
556+
[cols="h,e,m,h,h"]
557+
|===
558+
| 15:30
559+
| backup6
560+
| DIFF
561+
| 31
562+
| 50
563+
|===
564+
565+
In this case, the `backup3` is selected as the parent since it is the *latest non-empty differential* backup.
566+
567+
======
568+
[role=include-with-Chain-with-only-full-backups]
569+
======
570+
571+
Let's assume that you write 10 transactions to the `neo4j` database every hour and trigger an hourly full backup.
572+
573+
[cols="h,e,m,h,h"]
574+
|===
575+
|Timestamp | Backup name | Backup type | Lower Transaction ID | Upper Transaction ID
576+
577+
| 10:30
578+
| backup1
579+
| FULL
580+
| 1
581+
| 10
582+
583+
| 11:30
584+
| backup2
585+
| FULL
586+
| 11
587+
| 20
588+
|===
589+
590+
In this case, there is no differential backup.
591+
Therefore, the `--prefer-diff-as-parent` option has no effect and the behaviour is the same as the default one.
592+
593+
[source,shell]
594+
----
595+
neo4j-admin database backup \
596+
--from=<address:port> --to-path=<targetPath> \
597+
--type=DIFF --prefer-diff-as-parent \
598+
neo4j
599+
----
600+
601+
The result would be (with or without the `--prefer-diff-as-parent` option):
602+
[cols="h,e,m,h,h"]
603+
|===
604+
| 12:30
605+
| backup3
606+
| DIFF
607+
| 21
608+
| 30
609+
|===
610+
611+
======
612+
=====

0 commit comments

Comments
 (0)