# Incremental backups based on full backups

**URL:** <https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475>\
**Category:** Percona XtraBackup\
**Tags:** community, mysql, percona\
**Created:** [December 5, 2024, 8:03am UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475 "2024-12-05T08:03:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishnadas\_K\_P](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/krishnadas_k_p/32/18768_2.png) [@Krishnadas\_K\_P](https://forums.percona.com/u/Krishnadas_K_P)\
**Post date:** [December 5, 2024, 8:03am UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/1 "2024-12-05T08:03:01Z")

</div>

I am setting up automated full backups and incremental backups as per the below documentation.

> **[Percona XtraBackup - Backup example](https://docs.percona.com/percona-xtrabackup/8.0/example-full-incr.html#hourly-incremental-backup-script)**
>
> This example demonstrates how a beginner DBA can set up daily full backups and hourly incremental backups for a large organization using Percona XtraBackup 8.0 with a Percona Server for MySQL 8.0 database server.

Going through the script, I understand that every time incremental backup is triggered, it is based on the same full backup of the day. Shouldn’t this always be based on the previous backup which could be an incremental backup as well ? Is the script wrong or am I understanding the process incorrectly ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Yunus](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/yunus/32/6430_2.png) [@Yunus](https://forums.percona.com/u/Yunus)\
**Post date:** [December 5, 2024, 8:27am UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/2 "2024-12-05T08:27:29Z")

</div>

> [@Krishnadas\_K\_P](#):
>
> Going through the script, I understand that every time incremental backup is triggered, it is based on the same full backup of the day.

Your understanding is correct. The documentation specifies that you take a full backup and then the incremental hourly backups are taken with the base as full backup.

> [@Krishnadas\_K\_P](#):
>
> Shouldn’t this always be based on the previous backup which could be an incremental backup as well ?

You can set the base backup as previous incremental backup too and that is how you can tweak the script.  
You should also consider that you don’t end up taking incremental backups for a long long time. so that when you restore then you need to restore number of incremental backups.  
That is just an example script but you can off course set it according to your requirement.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [December 5, 2024, 2:18pm UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/3 "2024-12-05T14:18:35Z")

</div>

Hey @Krishnadas_K_P

> [@Yunus](#):
>
> The documentation specifies that you take a full backup and then the incremental hourly backups are taken with the base as full backup.

This actually creates “differential” backups. A differential backup is a type of incremental which always starts from the original full backup. Yes, incremental backups should reference the previous incremental.

As Yunus said, do not take incrementals often. You will add unnecessary load to the system. Your MySQL server already has a way to replay transactions, called the binary log.

The best practice is to take a daily full backup, and also backup the binary logs. This allows for point-in-time recovery. Restore the full, replay the binlogs.

Incremental backups are useful to shrink the gap between full and last binlog entry.

---

<div class="post-metadata">

**Author:** ![Krishnadas\_K\_P](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/krishnadas_k_p/32/18768_2.png) [@Krishnadas\_K\_P](https://forums.percona.com/u/Krishnadas_K_P)\
**Post date:** [December 6, 2024, 8:46am UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/4 "2024-12-06T08:46:15Z")

</div>

Thank you very much @matthewb.

I have setup binlog purging only after 7 days. If I have a daily full backup, I should be able to PITR to atleast 7 days even without incremental backups I think. Is that correct ?

---

<div class="post-metadata">

**Author:** ![Krishnadas\_K\_P](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/krishnadas_k_p/32/18768_2.png) [@Krishnadas\_K\_P](https://forums.percona.com/u/Krishnadas_K_P)\
**Post date:** [December 6, 2024, 8:46am UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/5 "2024-12-06T08:46:41Z")

</div>

Thanks @Yunus for the prompt response

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [December 6, 2024, 7:11pm UTC](https://forums.percona.com/t/incremental-backups-based-on-full-backups/35475/6 "2024-12-06T19:11:02Z")

</div>

> [@Krishnadas\_K\_P](#):
>
> I have setup binlog purging only after 7 days. If I have a daily full backup,

Once you create a full backup, you can delete all binary logs that came before because the full backup represents a snapshot in time. Restoring that puts your data at, for example, 03:44. Then you replay binary logs to bring you to 18:32. You would keep more binary logs in case you needed to go back to previous day, or days before full backup and play forward.

If you take a full backup on Sunday, you can, in theory, never take a backup again until Saturday since you have 7 days of binlogs, correct. You would restore that full from Sunday, then replay to any point.
