Skip to content

Commit 6689dfd

Browse files
Frannie-LudmillaNataliaIvakina
authored andcommitted
Add extra cases
1 parent bd37f5b commit 6689dfd

File tree

1 file changed

+187
-0
lines changed

1 file changed

+187
-0
lines changed

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

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,193 @@ You can use the latest differential backup as the parent by setting the option `
471471
This can be used to ensure you have differential backups for all transactions, which would allow you to restore to any point in time.
472472
Otherwise, the transactions between a full backup and the previous differential backup will not be backed up as individual transactions.
473473

474+
[.tabbed-example]
475+
=====
476+
Different scenarios for using the `--prefer-diff-as-parent` option
477+
[NOTE]
478+
The general behaviour while taking a differential backup with the `--type=DIFF` option is that the *most recent non-empty* backup is used as the parent.
479+
With the `--prefer-diff-as-parent` option, the *most recent non-empty differential* backup is used as the parent *when possible*:
480+
in case there is no backup that satisfy the condition, then we fall back to the general behaviour.
481+
======
482+
483+
Example 1: *Chain with full and differential backups*
474484

485+
Let's assume that every hour we write 10 transactions to the `neo4j` database, except from 12:30-13:30, when we don't write any transaction.
486+
There is a backup job that takes a backup every hour and a full backup every 4 hours.
487+
We refer as an _empty_ backup a backup that has no transactions, meaning that both the lower transaction ID and the upper transaction ID are zero)
488+
Let's say that you have this backup chain:
489+
490+
[cols="h,e,m,h,h"]
491+
|===
492+
|Timestamp | Backup name | Backup type | Lower Transaction ID | Upper Transaction ID
493+
494+
| 10:30
495+
| backup1
496+
| FULL
497+
| 1
498+
| 10
499+
500+
| 11:30
501+
| backup2
502+
| DIFF
503+
| 11
504+
| 20
505+
506+
| 12:30
507+
| backup3
508+
| DIFF
509+
| 21
510+
| 30
511+
512+
| 13:30
513+
| backup4
514+
| DIFF
515+
| 0
516+
| 0
517+
518+
| 14:30
519+
| backup5
520+
| FULL
521+
| 1
522+
| 40
523+
524+
|===
525+
526+
If at 15:30 we execute the backup command:
527+
[source,shell]
528+
----
529+
neo4j-admin database backup --from=<address:port> --to-path=<targetPath> --type=DIFF neo4j
530+
----
531+
532+
then the result would be:
533+
534+
[cols="h,e,m,h,h"]
535+
|===
536+
| 14:30
537+
| backup6
538+
| DIFF
539+
| 41
540+
| 50
541+
|===
475542

543+
because we choose `backup5` as parent since it is the *latest non-empty* backup.
476544

545+
Otherwise, if we execute this command:
546+
547+
[source,shell]
548+
----
549+
neo4j-admin database backup --from=<address:port> --to-path=<targetPath> --type=DIFF --prefer-diff-as-parent neo4j
550+
----
551+
552+
then the result would be:
553+
[cols="h,e,m,h,h"]
554+
|===
555+
| 14:30
556+
| backup6
557+
| DIFF
558+
| 31
559+
| 50
560+
|===
561+
562+
because we choose `backup3` as parent since it is the *latest non-empty differential* backup.
563+
564+
======
565+
566+
======
567+
568+
Example 2: *Chain with only full backups*
569+
570+
Let's assume that we write 10 transactions to the `neo4j` database every hour, and we trigger am hourly backup.
571+
572+
[cols="h,e,m,h,h"]
573+
|===
574+
|Timestamp | Backup name | Backup type | Lower Transaction ID | Upper Transaction ID
575+
576+
| 10:30
577+
| backup1
578+
| FULL
579+
| 1
580+
| 10
581+
582+
| 11:30
583+
| backup2
584+
| FULL
585+
| 11
586+
| 20
587+
|===
588+
589+
In this case, there is no differential backup, so the `--prefer-diff-as-parent` option has no effect and the behaviour is the same as the default one.
590+
591+
[source,shell]
592+
----
593+
neo4j-admin database backup \
594+
--from=<address:port> --to-path=<targetPath> \
595+
--type=DIFF --prefer-diff-as-parent \
596+
neo4j
597+
----
598+
599+
The result would be (with or without the `--prefer-diff-as-parent` option):
600+
[cols="h,e,m,h,h"]
601+
|===
602+
| 12:30
603+
| backup3
604+
| DIFF
605+
| 21
606+
| 30
607+
|===
608+
609+
======
610+
611+
======
612+
Example 3: *Chain with only empty full backups*
613+
614+
Let's assume that the database is empty and that we don't write anything to it, while still taking hourly backups.
615+
616+
[cols="h,e,m,h,h"]
617+
|===
618+
|Timestamp | Backup name | Backup type | Lower Transaction ID | Upper Transaction ID
619+
620+
| 10:30
621+
| backup1
622+
| FULL
623+
| 0
624+
| 0
625+
626+
| 11:30
627+
| backup2
628+
| FULL
629+
| 0
630+
| 0
631+
|===
632+
633+
In this case with the `--type=DIFF` option we would fail both with the `--prefer-diff-as-parent` and the `default` behaviour,
634+
since we're looking for the *latest non-empty* backup and there are only empty backups.
635+
636+
[source,shell]
637+
----
638+
neo4j-admin database backup \
639+
--from=<address:port> --to-path=<targetPath> \
640+
--type=DIFF --prefer-diff-as-parent \
641+
neo4j
642+
----
643+
644+
But if we select the `--type=AUTO` option, the command will succeed and the result would be another empty full backup.
645+
646+
[source,shell]
647+
----
648+
neo4j-admin database backup \
649+
--from=<address:port> --to-path=<targetPath> \
650+
--type=AUTO --prefer-diff-as-parent \
651+
neo4j
652+
----
653+
654+
[cols="h,e,m,h,h"]
655+
|===
656+
| 12:30
657+
| backup3
658+
| FULL
659+
| 0
660+
| 0
661+
|===
662+
663+
======

0 commit comments

Comments
 (0)