From d5e948ff953f63c676f0c38aa3e4239dcd075210 Mon Sep 17 00:00:00 2001 From: weimens <4752766+weimens@users.noreply.github.com> Date: Tue, 21 Jun 2022 15:58:08 +0200 Subject: [PATCH] Add documentation for the clean_db_records script. --- manual/maintain/clean_database.md | 67 ++++--------------------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/manual/maintain/clean_database.md b/manual/maintain/clean_database.md index 3d39a9010..08e4fffec 100644 --- a/manual/maintain/clean_database.md +++ b/manual/maintain/clean_database.md @@ -18,71 +18,20 @@ cd /seafile-server-latest ./seahub.sh python-env python3 seahub/manage.py clearsessions ``` -### Activity +### Clean DB Records -To clean the activity records, login in to MySQL/MariaDB and use the following command: +Since version 8.0, we offer command to clear login, activity, file access, file update, file history and permisson records in Seahub database. +For version 8.0, all records older that 90 days will be deleted ``` -use seahub_db; -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. - -Since version 7.0, the table Activity is used intead of Event. Correspondingly, you need to empty the Activity table. - -Use the following command: - -``` -use seahub_db; -DELETE FROM Activity WHERE to_days(now()) - to_days(timestamp) > 90; -``` - -The corresponding items in UserActivity will deleted automatically by MariaDB when the foreign keys in Activity table are deleted. - -### Login - -To clean the login records, login in to MySQL/MariaDB and use the following command: - -``` -use seahub_db; -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: - -``` -use seahub_db; -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: - -``` -use seahub_db; -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: - -``` -use seahub_db; -DELETE FROM PermAudit WHERE to_days(now()) - to_days(timestamp) > 90; +cd /seafile-server-latest +./seahub.sh python-env python3 seahub/manage.py clean_db_records ``` -### File History - -To clean the file history records, login in to MySQL/MariaDB and use the following command: - +For version 10 and later there is an keep days option, all records that are older that this will be deleted. ``` -use seahub_db; -DELETE FROM FileHistory WHERE to_days(now()) - to_days(timestamp) > 90; +cd /seafile-server-latest +./seahub.sh python-env python3 seahub/manage.py clean_db_records --days 120 ``` ### Outdated Library Data