photo of optical disc drive

Seafile Garbage Collection Guide

Seafile servers may accumulate unused “blocks” of storage over time, necessitating manual garbage collection. This guide walks you through the steps to perform this process.

Why Garbage Collection?

When files or libraries are deleted, unused blocks can remain due to Seafile’s history settings and data deduplication. These blocks aren’t automatically purged because Seafile needs to preserve them until it’s certain they are no longer needed. Running garbage collection allows Seafile to safely remove these blocks.

Steps to Perform Garbage Collection

Stop Seafile Server Processes

Before running garbage collection, stop the Seafile processes to prevent any new blocks from being mistakenly deleted

seafile-server-latest/seafile.sh stop
seafile-server-latest/seahub.sh stop

This streamlined process ensures that your Seafile server runs efficiently by removing unused storage blocks without risking data loss.

Run the Garbage Collection Script

Navigate to the Seafile directory and execute the garbage collection script:

cd /seafile/seafile-server-latest
./seaf-gc.sh

The process may take some time. You’ll see output indicating the progress of the garbage collection, including details like the number of blocks processed and removed.

Review the Results

Once complete, you’ll see a list of repositories that were deleted by users and are now removed from the system.

[08/09/24 04:15:17] gc-core.c(384): === Repos deleted by users ===
[08/09/24 04:15:17] gc-core.c(392): GC deleted repo eb0ebd0a.
...
[08/09/24 04:15:59] gc-core.c(456): === GC is finished ===
seafserv-gc run done

Restart Seafile

After the garbage collection is complete, restart the Seafile processes:

seafile/seafile-server-latest/seafile.sh start
seafile/seafile-server-latest/seahub.sh start

This streamlined process ensures that your Seafile server runs efficiently by removing unused storage blocks without risking data loss.

Photo by Patrick Lindenberg on Unsplash

Leave a Reply

Your email address will not be published. Required fields are marked *