# pt-archiver: multiple dependent tables?

**URL:** <https://forums.percona.com/t/pt-archiver-multiple-dependent-tables/4069>\
**Category:** Percona Toolkit\
**Created:** [February 23, 2015, 1:16pm UTC](https://forums.percona.com/t/pt-archiver-multiple-dependent-tables/4069 "2015-02-23T13:16:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeichhorn](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jeichhorn](https://forums.percona.com/u/jeichhorn)\
**Post date:** [February 23, 2015, 1:16pm UTC](https://forums.percona.com/t/pt-archiver-multiple-dependent-tables/4069/1 "2015-02-23T13:16:37Z")

</div>

Hi,

does the pt-archiver tool allows to archive multiple dependent tables in a single run?

Example:

- Table A has the column(s) with the functional archive critera (e.g. archive all rows where date\_column older than 3 months)
- Table B references table A
- Table C contains rows which reference rows in table B
- Table C contains rows which has no references to table B and date\_column older than 3 months
- …

I would like to archive all rows which match the example to a different MySQL instance on a different host

Thanks for help,  
Jörg

---

<div class="post-metadata">

**Author:** ![jrivera](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/jrivera/32/13_2.png) [@jrivera](https://forums.percona.com/u/jrivera)\
**Post date:** [April 2, 2015, 7:32am UTC](https://forums.percona.com/t/pt-archiver-multiple-dependent-tables/4069/2 "2015-04-02T07:32:24Z")

</div>

I think you can make use of pt-archiver’s --plugin module functionality ([url][pt-archiver — Percona Toolkit Documentation](http://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html#cmdoption-pt-archiver--plugin%5B/url%5D) and [url][pt-archiver — Percona Toolkit Documentation](http://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html#extending%5B/url%5D)) to suite your needs.

---

<div class="post-metadata">

**Author:** ![thekalinga](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@thekalinga](https://forums.percona.com/u/thekalinga)\
**Post date:** [May 3, 2015, 7:33am UTC](https://forums.percona.com/t/pt-archiver-multiple-dependent-tables/4069/3 "2015-05-03T07:33:42Z")

</div>

[jrivera](https://www.percona.com/forums/member/21266-jrivera),

The details for cascade archive and insert is not clear from the documentation. Would you mind sharing an example of how the cascaded archive & cascaded insert can be performed.

I assume this is the most common use case for many products.

I am specifically referring to these sections in the documentation before\_insert(row =\> @row)  
[INDENT] This method is called for each row just before it is inserted. This applies only to [–dest](https://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html#cmdoption-pt-archiver--dest). You could use this to insert the row into multiple tables, perhaps with an ON DUPLICATE KEY UPDATE clause to build summary tables in a data warehouse.  
This method is not called if [–bulk-insert](https://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html#cmdoption-pt-archiver--bulk-insert) is given.  
[/INDENT] before\_delete(row =\> @row)  
[INDENT] This method is called for each row just before it is deleted. This applies only to [–source](https://www.percona.com/doc/percona-toolkit/2.1/pt-archiver.html#cmdoption-pt-archiver--source). This is a good place for you to handle dependencies, such as deleting things that are foreign-keyed to the row you are about to delete. You could also use this to recursively archive all dependent tables.

[/INDENT]
