If you accidentally delete files from a General-purpose Apsara File Storage NAS file system, you can restore the files and the metadata of the files, such as UID, GID, and ACL, from the NAS recycle bin.
Background information
- 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, if the test_a.txt file and the test_b.txt file reside in the same directory and 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 modify 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.
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 IA storage media.
- Permissions
Only the owner of a file system or authorized 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 .
- On the File System List page, click the ID of the file system that you want to manage.
- On the details page of the file system, click Recycle Bin and then click Enable Recycle Bin.
- In the Enable Recycle Bin dialog box, set Select Retention Period to 3 Days and click OK.
Restore files from the recycle bin
- Each file system allows you to run only one restoration task at a time. You cannot create a file restoration task when a file is being restored.
- A restoration task can restore only one file or directory. If you restore a specific directory, all files in the directory are restored. Note If 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 restoration task is displayed as Partially Completed.
- The time that is required by a restoration task 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 .
- On the File System List page, click the ID of the file system that you want to manage.
- On the details page of the file system, click Recycle Bin.
- On the Recycle Bin page, 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 OK.
- 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.
Note- If the restoration task is in the Defragmenting state, the read performance of the file is slightly reduced. 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 task 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.
What to do next
Operation | Description | Procedure |
---|---|---|
Empty a recycle bin | If you no longer need the files in a 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 the retention period of files | 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 files that are temporarily stored in the recycle bin. |
|
Disable and empty a recycle bin | If you disable a recycle bin, all files in the recycle bin are permanently deleted. If you disable and then enable a recycle bin, the recycle bin is empty. You cannot retrieve the deleted files. |
|
Query files in a 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 a recycle bin | If you permanently delete a specific directory from a 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 tasks of a recycle bin | In the NAS console, you can view the data restoration tasks or permanent deletion tasks that are run in the previous seven days. The NAS console can show up to 50 task records. |
|
Cancel a permanent deletion task or a data restoration task | If a data restoration task or a permanent deletion task is in the Running state, you can cancel the task in the NAS console.
|
|