If you accidentally delete files from a General-purpose File Storage NAS (NAS) file system, your business may be interrupted or your data may be permanently lost. To prevent these issues, we recommend that you enable the recycle bin feature. After you enable the recycle bin feature, deleted files and directories are temporarily stored in the recycle bin. The files and directories are permanently deleted from the recycle bin after a specified retention period. During the data retention period, you can restore these files and directories and their metadata such as user identifiers (UIDs), group identifiers (GIDs), and access control lists (ACLs).
Background information
If you enable the recycle bin feature, the deleted files or directories are temporarily stored in the recycle bin, including but not limited to the following files and directories:
The files that you deleted from NAS file systems on compute nodes, such as Elastic Compute Service (ECS) instances and containers. For example, if you run the
rm -f test01.text
command to delete the test01.text file, the test01.text file is dumped to the recycle bin.The files or directories that are automatically deleted by applications from NAS file systems on compute nodes. For example, if an application runs the
os.remove("test02.text")
Python code to delete the test02.text file, the test02.text file is dumped to the recycle bin.The files or directories that are deleted when you call the POSIX rename function. For example, the test_a.txt file and the test_b.txt file reside in the same directory. If you run the
mv test_a.txt test_b.txt
command, the test_b.txt file is dumped to the recycle bin.The temporary files that are created when applications use NAS files. For example, if you run the vim command to edit a file, the
.swp
and.swpx
temporary files are dumped to the recycle bin.The application log files that are automatically rotated. For example, if you use NGINX to configure automatic log rotation, up to 20 log files can be retained. If the test.log.19 log file is rotated to the test.log.20 log file, the original test.log.20 log file is dumped to the recycle bin.
If you overwrite a file but do not delete the file, the file is not dumped to the recycle bin. For example, if you call the open()
function to open a file and write data to the file in w+
mode, the original file is not dumped to the recycle bin.
Usage notes
Billing
You are not charged for enabling the recycle bin feature. However, you are charged for the storage space occupied by files that are temporarily stored in the recycle bin. The storage fees are calculated based on the storage type of the files before the files are deleted. To reduce storage costs, we recommend that you specify a retention period for files. For more information, see Billing of General-purpose NAS file systems and Billing of the IA storage class.
Permissions
Only the owner of a file system or authorized Resource Access Management (RAM) users can use the recycle bin feature. For more information, see Perform access control based on RAM policies.
Enable the recycle bin feature
If you enable the recycle bin feature, the files that you delete are dumped to the recycle bin. The files are permanently deleted from the recycle bin after a specified retention period. To enable the recycle bin feature, perform the following steps:
Log on to the NAS console.
In the left-side navigation pane, choose File System > File System List.
In the top navigation bar, select a region.
On the File System List page, click the ID of the file system.
On the details page of the file system, click the Recycle Bin tab and then click Enable Recycle Bin.
In the Enable Recycle Bin dialog box, set Select a retention period.
Click OK.
Restore files from the recycle bin
You can restore files from the recycle bin within the retention period that you specify. Before you run restore jobs, take note of the following information:
Each file system allows you to run only one restore job at a time. You cannot create a file restore job when a file is being restored.
A restore job can restore only one file or directory. If you restore a specific directory, all files in the directory are restored.
NoteIf the number of hard links to a file in the directory that you want to restore exceeds 511, NAS randomly restores 511 of these files to the directory. The excess files cannot be restored. The status of the restore job is displayed as Partially Completed.
The time that is required by a restore job increases with the number of files or directories that you want to restore.
To restore the files that are temporarily stored in the recycle bin, perform the following steps:
Log on to the NAS console.
In the left-side navigation pane, choose File System > File System List.
In the top navigation bar, select a region.
On the File System List page, click the ID of the file system.
On the details page of the file system, click Recycle Bin.
On the Deleted Files and Directories tab, find the file that you want to restore and click Restore.
In the Select Restoration Path dialog box, select the path to which you want to restore the file and click Select Restoration Path.
Restore to the original path: If the path from which you deleted the file still exists, the file is restored to the path. If the original path does not exist, select a custom path.
Restore to the following custom path: Select an existing path to which you want to restore the file.
NoteIf the restore job is in the Defragmenting state, the read performance of the file is slightly degraded. We recommend that you do not change the directory structure of the file system. If you change the directory structure of the file system, the defragmentation is delayed.
If the job is in the Completed state and you cannot find the files that are restored to the specified path by running the ls command on the ECS instance, run the
sudo sysctl -w vm.drop_caches=2
command on the ECS instance to clear the cache. After you clear the cache, you can find the files.
Related operations
Operation | Description | Procedure |
Empty Recycle Bin | If you no longer need the files in the recycle bin, you can empty the recycle bin to reduce storage costs. Warning If you empty the recycle bin, all files in the recycle bin are permanently deleted and cannot be retrieved. |
|
Change File Retention Period | You can change the retention period of files at any time based on the usage of the file system. This way, you can reduce the storage cost of the files that are temporarily stored in the recycle bin. |
|
Disable and Empty | After you confirm that you no longer need the files in the recycle bin or that you no longer want to use the recycle bin feature, you can disable and empty the recycle bin. Warning
|
|
Query files in the recycle bin | You cannot query the files that are temporarily stored in the recycle bin on a compute node. You can query the files only in the NAS console. | On the Recycle Bin page, you can query the files that are temporarily stored in the recycle bin. You can also query the point in time at which the files are deleted. |
Permanently delete files from the recycle bin | If you permanently delete a specific directory from the recycle bin, all files in the directory are permanently deleted. Warning After you permanently delete the files from the recycle bin, you cannot retrieve the files. |
|
Query the jobs of the recycle bin | In the NAS console, you can view the data restore jobs or permanent deletion jobs that are run in the previous seven days. The NAS console can show up to 50 job records. |
|
Cancel a permanent deletion job or a data restore job | If a data restore job or a permanent deletion job is in the Running state, you can cancel the job in the NAS console.
|
|
References
To prevent NAS data loss or damage, you can use Cloud Backup to back up all directories or files in NAS file systems. For more information, see Back up and restore files.
For advanced Extreme NAS file systems, you can use snapshots to back up data and restore data from a snapshot at a point in time to an existing file system. For more information, see Manage snapshots.