Set Up A NAS To Automatically Delete Old Files Safely
A network-attached storage system can quietly accumulate downloads, surveillance footage, phone backups, temporary exports and duplicate media. Over time, a NAS may run short of capacity even when its hard drives appeared generously sized at purchase. An age-based retention policy removes files after a defined period, keeping storage predictable without requiring constant manual sorting.
Automatic deletion is useful for households, home offices and small businesses across Australia. A Brisbane family might retain security-camera recordings for 14 days, while a Melbourne photographer may keep project exports for 90 days. The right rule depends on how quickly files lose value, whether they can be recreated and whether a legal or insurance requirement applies.
The important distinction is between disposable data and irreplaceable data. A downloaded television episode, cached thumbnail or temporary render can usually be removed. Tax records, family photos, client documents and the only copy of a business database should be protected with backups rather than placed under an aggressive cleanup schedule.
Before creating a task, check available NAS capacity, the folder structure and the recovery path. Deletion automation should be easy to audit, limited to specific directories and tested with harmless sample files. A RAID array can keep a NAS running after a drive failure, but RAID does not recover a file deliberately deleted by an automated job.
| Use case | Sensible starting age | Safer implementation |
|---|---|---|
| CCTV and doorbell recordings | 7–30 days | Delete by recording date; preserve flagged clips |
| Downloads and temporary work | 14–60 days | Use a dedicated staging folder |
| Media server artwork and transcodes | 30–90 days | Remove generated files, retain originals |
| Shared business documents | Usually no automatic deletion | Archive and back up instead |
| Device logs | 30–180 days | Rotate by size and age, then compress |
Define A Retention Policy First
Start by writing down what “old” means for each folder. File creation time, modification time and last access time can produce different results. A file copied from a USB drive may have an old creation date even though it is newly added to the NAS, while access-time tracking may be disabled or unreliable.
A practical policy uses dedicated folders such as /downloads, /camera/archive, /transcodes and /temp. Avoid applying one global rule to a share that contains both disposable material and permanent records. The folder name, owner and retention period should make the intended behaviour obvious to anyone managing the NAS later.
Consider the Australian context before deleting business information. Australian Taxation Office records may need to be retained for several years, and privacy obligations can apply to personal information. A small business in Parramatta or Geelong should check its accountant’s advice and industry requirements rather than assuming that a seven-day cleanup is acceptable.
Choose Native Tools Or Scripts
Synology DSM and QNAP QTS both provide scheduled tasks, file management utilities and package ecosystems that can support automated housekeeping. Native tools are generally easier to maintain after a firmware update, while a shell script provides finer control over filename patterns, exclusions and logging.
For straightforward cleanup, use a separate shared folder and a scheduled job that selects files older than a defined number of days. The command should operate on files first, exclude hidden system directories and write a report before it removes anything. A dry-run mode is valuable because it shows the proposed deletions without changing data.
Scripts should use absolute paths and quote filenames correctly. Spaces, apostrophes and non-English characters are common in household media libraries. Avoid a broad command pointed at the root of a volume, and do not rely on a wildcard that could expand into unexpected directories.
Configure Synology DSM Carefully
On a Synology NAS, a scheduled task can be created in Control Panel under Task Scheduler. A common pattern is to run a shell script that searches a single target folder, selects regular files older than a chosen age and records each action in a log file. The task can run weekly rather than hourly when the folder contains ordinary downloads.
Synology Drive, Hyper Backup and Active Backup may create versioned data or deduplicated repositories that should not be cleaned with a simple age command. Their retention controls belong inside the relevant application. Removing files from an application-managed directory can break its database or make recovery points unusable.
For media libraries, Plex or Jellyfin metadata and transcoded content should be separated from original recordings. A cleanup rule can target the transcode directory while leaving the source video untouched. Run the task as a user with the smallest permissions needed, then review DSM notifications after the first execution.
Configure QNAP QTS With Clear Boundaries
QNAP users can schedule scripts through QTS task facilities or a supported command-line method, depending on the model and firmware version. The exact menu can change, so record the task name, command, schedule and destination before applying an update. A dedicated shared folder is safer than a rule aimed at an entire storage pool.
HBS 3, Snapshot Replica and backup applications have their own retention and version-pruning options. Configure those policies within the application rather than deleting files from its repository manually. For surveillance systems, QVR Elite or another recording application should control recording retention where possible, since it understands locked events and camera-specific storage.
Container Station can run tools that manage temporary application data, but containers add another layer of paths and permissions. Confirm whether a folder is mounted from the NAS and test deletion inside a non-production directory. A task that works on a Linux shell may fail when the container user cannot write to the host share.
Protect Data Before The First Deletion
A backup is the safety net for an incorrect retention rule. The 3-2-1 approach remains useful: keep three copies, on two types of storage, with one copy disconnected or off-site. For an Australian household, that might mean the NAS, a USB backup rotated away from the house and encrypted cloud storage.
Snapshots can help with accidental changes, but they are not a complete substitute for a separate backup. If ransomware or a faulty script reaches the NAS, snapshots stored on the same system may also be affected. Enable immutable or protected snapshots where the NAS model and filesystem support them, and test restoration rather than trusting a green backup status.
Deletion should also account for recycle bins. Synology and QNAP shared folders may move deleted material into a hidden recycle directory, which means the volume does not actually regain space. If the policy is designed to reclaim storage, schedule a separate, carefully limited recycle-bin purge after a review period.
Build Checks Into The Automation
The safest cleanup job reports first and deletes second. Send output to a dedicated log location, include the execution time and count of selected files, and configure email or push notifications for failures. Monitoring can reveal a camera share filling rapidly or a task that stopped after a NAS restart. A centralised log server can collect these events alongside router, switch and application logs.
Use a short test period with files whose names clearly indicate their purpose. Set their timestamps to represent different ages, run the task manually or against a test folder, and confirm that only the intended files are selected. Once the results are correct, move the schedule to the production folder and retain the first several reports.
Useful pre-deletion checks include:
- Confirming the target path is a dedicated temporary or archive folder
- Excluding backup repositories, snapshots and application databases
- Recording the number and total size of files selected
- Checking that the NAS clock and time zone are correct
- Sending an alert when the deletion count is unexpectedly high
After the task runs, review these operational signals:
- Available pool capacity before and after cleanup
- Failed jobs caused by locked files or permission errors
- Recycle-bin growth that offsets reclaimed space
- Backup completion and recent restore-test results
- Changes after DSM, QTS or application upgrades
Tune The Schedule For Australian Conditions
Australian homes often have mixed connectivity and power conditions. NBN service may be fast enough for cloud backups but still suffer evening congestion, so schedule large uploads outside peak household use. A NAS in a garage or shed in Western Sydney, Adelaide or Perth may also face higher heat than a ventilated indoor office; storage monitoring and fan maintenance matter when cleanup jobs trigger disk activity.
Power interruptions can occur during storms, bushfire events or local infrastructure faults. A UPS gives the NAS time to shut down cleanly and reduces the chance that a scheduled task is interrupted while files are being written. Set the NAS to resume safely after power returns, then verify that scheduled jobs do not run twice or act on partially transferred files.
Retention should reflect how people actually use the data. A FIFO-style camera policy may keep the latest 21 days, while a family in regional New South Wales may need longer because an unreliable internet connection delays off-site backup. In a small office near the Gold Coast, keeping temporary exports for 30 days may be enough, provided the final documents are stored in a protected project folder.
Review the policy every few months and after major changes such as adding cameras, migrating from USB storage or enabling a new backup application. Keep a written record of each folder’s purpose, retention period and backup status. That documentation turns automatic deletion from a risky shortcut into a controlled part of NAS administration.
Choose one low-risk folder, create a backup and test a dry run before enabling removal. Keep the task narrowly scoped, inspect its logs after each early run and expand coverage only when the results match the policy. With clear boundaries and recoverable data, your Synology or QNAP NAS can stay tidy, responsive and ready for the files that genuinely matter.