# Archiving data over date range.

**URL:** <https://forums.percona.com/t/archiving-data-over-date-range/1655>\
**Category:** Other MySQL® Questions\
**Created:** [August 22, 2011, 3:55am UTC](https://forums.percona.com/t/archiving-data-over-date-range/1655 "2011-08-22T03:55:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![slnp](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@slnp](https://forums.percona.com/u/slnp)\
**Post date:** [August 22, 2011, 3:55am UTC](https://forums.percona.com/t/archiving-data-over-date-range/1655/1 "2011-08-22T03:55:41Z")

</div>

Hello Everyone,

I am looking at a better solution for archiving large amounts of data over a date range. At the moment I am using a script that I created that creates a temporary table and inserts data into it using the following query:

INSERT INTO temp\_candata SELECT \* FROM candata WHERE timestamp between ‘2011-02-01 00:00:00’ and ‘2011-03-01 00:00:00’

Then I use mysqldump to dump the table, tar it and then delete it.

I know this method is not elegant or optimal. The time it takes to archive is much longer than I think it could be.

I had a quick look at mk-archiver but I am unsure of how to get the data from a specific date range.

Can anyone suggest a way I could do this?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![gmouse](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@gmouse](https://forums.percona.com/u/gmouse)\
**Post date:** [August 22, 2011, 5:56am UTC](https://forums.percona.com/t/archiving-data-over-date-range/1655/2 "2011-08-22T05:56:42Z")

</div>

[URL][http://www.maatkit.org/doc/mk-archiver.html[/URL]](http://www.maatkit.org/doc/mk-archiver.html%5B/URL%5D)  
As you can see, there is a --where option that can be set to “timestamp between ‘2011-02-01 00:00:00’ and ‘2011-03-01 00:00:00’”. Try --dry-run first if you are experimenting.

---

<div class="post-metadata">

**Author:** ![slnp](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@slnp](https://forums.percona.com/u/slnp)\
**Post date:** [August 22, 2011, 6:05am UTC](https://forums.percona.com/t/archiving-data-over-date-range/1655/3 "2011-08-22T06:05:01Z")

</div>

Thank you for the reply.

When I run

xxxx@xxxx:~/mysql\_files$ mk-archiver --source h=localhost,D=xxxx,t=datavalue --purge --where ‘timestamp \< ‘2011-03-01 00:00:00’’

I get the output:

Usage: /usr/bin/mk-archiver --source DSN --where WHERE

Errors in command-line arguments:

- Unrecognized command-line options 00:00:00

mk-archiver nibbles records from a MySQL table. The --source and --dest  
arguments use DSN syntax; if COPY is yes, --dest defaults to the key’s value  
from --source. For more details, please use the --help option, or try ‘perldoc  
/usr/bin/mk-archiver’ for complete documentation.
