# Cleanup Database

The NATS [Supported & Maintenance Admin](https://docs.toomuchmedia.com/nats-admin/support-and-maintenance) allows you to remove old, unnecessary information from your NATS database and logs. As a necessary precaution, NATS will not allow you to remove information vital to payments, payouts, or statistics in this admin

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FUUjtCFtLxDab4MeRCsVQ%2Fnatsadmin-support%26maintenance-%20cleanupdatabase.png?alt=media&#x26;token=bcc26bd1-178a-4c82-a547-c2b0b9b45e6c" alt=""><figcaption></figcaption></figure>

## Cleaning Your Database

To clean up a database table, click the "Clean Table" icon, which is marked by a broom. On the next page, you can select the Max Number of Rows you would like to clean up, and what kind of backup you wish to run.

NATS offers multiple formats to back up your database: MySQL Dumps, CSV dumps, and no backup. All database cleanings create a SQL-formatted backup of the data to be removed and place it in the *nats/backups* directory for storage.

Cleanings can often take a long time to run, so NATS runs the database cleanup as a background process, allowing you to keep working while the database is cleaning. Database rows are also deleted incrementally so that your database table won't be locked for a long time.

Tables that should be cleaned soon will be bold and colored red. You can clean a table by clicking on the Clean Table icon to its right or view information about the table by clicking on the View Table icon.

After you click the Clean Table icon, you will be taken to a page where you can configure settings for the cleanup. Available settings include:

* **Rows Before** - all rows before whatever date you input will be cleaned.
* **Max # Rows** - this determines the maximum amount of rows NATS will clean at a time
* **Run Backup** - select whether you want a MySQL Dump, a CSV Dump, or no dump

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2Fh5a13IacrgWlVKVAEQIY%2Fnatsadmin-support%26maintenance-%20cleanupdatabase-cleantriggerbiller.png?alt=media&#x26;token=fa2e223f-89f6-475b-ae6a-aed4ce710cae" alt=""><figcaption></figcaption></figure>

Once you have configured your settings, click the Clean button to start your cleanup.

## Cleaning Your Logs

NATS also offers an option to clean your server's logs through the Support & Maintenance Admin. Like database files, NATS will ensure that you do not remove information vital to statistics, payments, or payouts.

To clean your logs, go to the [Supported & Maintenance Admin](https://docs.toomuchmedia.com/nats-admin/support-and-maintenance) and click Logging from the left-hand navigation. On the next page, find the logs you wish to clean up, click the Actions button beside it and click the "Clean Up Log File" option.

You will then be taken to a page where you can configure settings for your cleanup. Available settings include:

* **Cleanup On** - allows you to select whether you want to sort your cleanup by date or by rows.
* **Rows Before** - all rows before whatever date you input will be cleaned.
* **Keep # Rows** - input the number of rows you want to save from your cleanup process

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FphlKT8XIVVUWiYeUeqiz%2Fnatsadmin-support%26maintenance-%20cleanupdatabase-cleanlogs.png?alt=media&#x26;token=6b42068c-fcac-4346-b898-ece44c9aa694" alt=""><figcaption></figcaption></figure>

Once you have configured your settings, click the Clean button to start your cleanup.
