Clean Database

Seahub

Session

Since version 5.0, we offered command to clear expired session records in Seahub database.

  1. cd <install-path>/seafile-server-latest
  2. ./seahub.sh python-env seahub/manage.py clearsessions

Activity

To clean the activity records, login in to MySQL/MariaDB and use the following command:

  1. use seahub_db;
  2. DELETE FROM Event WHERE to_days(now()) - to_days(timestamp) > 90;

The corresponding items in UserEvent will deleted automatically by MariaDB when the foreign keys in Event table are deleted.

Login

To clean the login records, login in to MySQL/MariaDB and use the following command:

  1. use seahub_db;
  2. DELETE FROM sysadmin_extra_userloginlog WHERE to_days(now()) - to_days(login_date) > 90;

File Access

To clean the file access records, login in to MySQL/MariaDB and use the following command:

  1. use seahub_db;
  2. DELETE FROM FileAudit WHERE to_days(now()) - to_days(timestamp) > 90;

File Update

To clean the file update records, login in to MySQL/MariaDB and use the following command:

  1. use seahub_db;
  2. DELETE FROM FileUpdate WHERE to_days(now()) - to_days(timestamp) > 90;

Permisson

To clean the permisson records, login in to MySQL/MariaDB and use the following command:

  1. use seahub_db;
  2. DELETE FROM PermAudit WHERE to_days(now()) - to_days(timestamp) > 90;

Outdated Library Data

Since version 6.2, we offer command to clear outdated library records in Seahub database,
e.g. records that are not deleted after a library is deleted. This is because users can restore a deleted library, so we can’t delete these records at library deleting time.

  1. cd <install-path>/seafile-server-latest
  2. ./seahub.sh python-env seahub/manage.py clear_invalid_repo_data