Enable the recycle bin for a general-purpose NAS file system to prevent accidental data loss. Deleted files and directories are retained for a specified period and can be restored along with their metadata, including UIDs, GIDs, and ACLs.
How the recycle bin works
After the recycle bin is enabled, deleted files and directories are moved to it automatically. Examples:
-
Files deleted manually from compute nodes such as ECS instances or containers. For example,
rm -f test01.textmoves test01.text to the recycle bin. -
Files or directories deleted by applications. For example, calling
os.remove("test02.text")in Python moves test02.text to the recycle bin. -
Files overwritten by a POSIX rename operation. For example,
mv test_a.txt test_b.txtmoves the original test_b.txt to the recycle bin when both test_a.txt and test_b.txt exist. -
Temporary files generated by applications. For example, vim creates
.swpand.swpxfiles that are moved to the recycle bin when removed. -
Log files removed during log rotation. For example, if Nginx retains 20 log files and test.log.19 is rotated to test.log.20, the existing test.log.20 is moved to the recycle bin.
Overwriting file content without deleting the file does not trigger a move to the recycle bin. For example, writing a file with open() in w+ mode does not move the file to the recycle bin.
Running rm -rf on large numbers of files can increase file system latency. To mitigate this, enable the recycle bin, delete files during off-peak hours, and then permanently remove them from the recycle bin in the console after confirming that services are running normally.
Billing and permissions
-
Billing
The recycle bin feature itself is free. However, files in the recycle bin still incur storage charges based on their original storage type. Set an appropriate retention period to avoid unnecessary costs. Billing for general-purpose NAS.
-
Permissions
Only the file system owner and authorized RAM users can manage the recycle bin. Grant RAM users permissions to manage the recycle bin.
Enable the recycle bin
To enable the recycle bin:
-
Log on to the NAS console.
-
In the navigation pane on the left, choose File System > File System List.
-
In the top navigation bar, select a region.
-
On the File Systems page, click the ID of the file system.
-
On the file system details page, click the Recycle Bin tab and then click Enable Recycle Bin.
-
In the Enable Recycle Bin dialog box, set the Retention Period in days.
-
Click OK.
Restore files from the recycle bin
You can restore files from the recycle bin within the retention period. Constraints:
-
Only one restore job runs at a time per file system.
-
Each restore job restores a single file or directory. Restoring a directory restores all files within it.
NoteIf a file in the directory has more than 511 hard links, NAS restores 511 at random. The remaining hard links cannot be restored, and the job status shows Partially Succeeded.
-
Restore duration increases with job size.
To restore a file or directory:
-
Log on to the NAS console.
-
In the navigation pane on the left, choose File System > File System List.
-
In the top navigation bar, select a region.
-
On the File Systems page, click the ID of the file system.
-
On the file system details page, click the Recycle Bin tab.
-
On the Deleted Files and Directories tab, find the target file or directory and click Restore.
-
In the Select Restoration Path dialog box, select a path to which you want to restore the file or directory and click Confirm.
-
Restore to the original path: Restores the file to its original path. If the original path no longer exists, use a custom path instead.
-
Custom recovery path: Restores the file to an existing path that you specify.
Note-
While the task status is Organizing, file system read performance may decrease slightly. Avoid changing the directory structure during this phase, as it extends the organization process.
-
If restored files are not visible when running ls on an ECS instance after a restore job completes, clear the instance cache by running
sudo sysctl -w vm.drop_caches=2and check again.
-
Additional operations
|
Actions |
Description |
Procedure |
|
Empty Recycle Bin |
Empty the recycle bin to reduce storage costs when you no longer need the deleted files. Warning
This operation permanently deletes all files in the recycle bin. Permanently deleted files cannot be recovered. |
|
|
Modify Retention Period |
Adjust the retention period at any time to manage storage costs. |
|
|
Disable and Empty |
Disable the recycle bin when it is no longer needed. Disabling permanently deletes all files in the recycle bin. Warning
|
|
|
View files in the recycle bin |
Files in the recycle bin are not accessible from compute nodes. Use the NAS console to view them. |
On the Recycle Bin tab, view deleted files, their deletion times, and other details. |
|
Permanently delete files from the recycle bin |
Permanently deleting a directory from the recycle bin deletes all files within it. Warning
Files that are permanently deleted from the recycle bin cannot be recovered. |
|
|
View recycle bin jobs |
View restore and permanent deletion jobs from the last 7 days. Up to 50 records are displayed. |
|
|
Cancel a permanent deletion or restore job |
Cancel jobs in the Restoring or Deleting state.
|
|
Related documents
-
Cloud Backup can back up all directories and files in a NAS file system. Back up and restore files.
-
Extreme NAS file systems support snapshot-based backup and restore. Snapshot.