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

After you enable the recycle bin feature, the deleted files or directories are temporarily stored in the recycle bin, including but are not limited to the following files and directories:
  • The files that you delete 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.
Note If you overwrite 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 into the file in w+ mode, the original file is not dumped to the recycle bin.

Usage notes

  • Billing rules

    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 configure a file retention period. 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.

  • Supported regions

    The recycle bin feature is available in the following regions: China (Beijing), China (Shanghai), China (Heyuan), China (Guangzhou), China (Hong Kong), Australia (Sydney), Malaysia (Kuala Lumpur), Indonesia (Jakarta), US (Silicon Valley), and US (Virginia).

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 the specified retention period. To enable the recycle bin feature, perform the following steps:

  1. Log on to the NAS console.
  2. In the left-side navigation pane, choose File System > File System List.
  3. On the File System List page, click the ID of the file system for which you want to enable the recycle bin.
  4. On the details page of the file system, click Recycle Bin, and then click Enable Recycle Bin.
  5. In the Enable Recycle Bin dialog box, set Select Retention Period to 3 Days and click OK.

Restore files from the recycle bin

You can restore files from the recycle bin within the retention period. Before you run restoration tasks, take note of the following information:
  • 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 specified directory, all files in the directory are restored.
    Note If more than 511 files are hard links to a file in the directory that you want to restore, NAS randomly restores 511 of these files to the directory. The excess files cannot be restored. Then, the status of the restoration task is displayed as Partially Completed.
  • The time required by a restoration task increases with the number of files or directories that needs to be restored.

To restore the files that are temporarily stored in the recycle bin, perform the following steps:

  1. Log on to the NAS console.
  2. In the left-side navigation pane, choose File System > File System List.
  3. On the File System List page, click the ID of the file system for which you want to enable the recycle bin.
  4. On the details page of the file system, click Recycle Bin.
  5. On the Recycle Bin page, find the file that you want to restore, and click Restore.
  6. 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. Otherwise, the defragmentation is delayed.
    • If the task is in the Completed state, you may fail query the files that are restored to the specified path by running the ls command on the ECS instance. In this case, run the sudo sysctl -w vm.drop_caches=2 command on the ECS instance to clear the cache. Then, you can query the files as expected.

Related operations

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 After you empty the recycle bin, all files in the recycle bin are permanently deleted and cannot be retrieved.
  1. On the Recycle Bin page, click Empty Recycle Bin.
  2. Confirm that you no longer need the files in the recycle bin, and click OK.
Change the 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 files that are temporarily stored in the recycle bin.
  1. On the Recycle Bin page, click Modify.
  2. In the Modify Retention Period dialog box, change the retention period and click OK.
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.

  1. On the Recycle Bin page, click Disable and Empty.
  2. Confirm that you no longer need the files in the recycle bin or no longer want to use the recycle bin feature. Click OK.
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 specified directory in a recycle bin, all files in the directory are permanently deleted.
Warning You cannot retrieve files after you permanently delete them from the recycle bin.
  1. On the Recycle Bin page, find the file that you no longer need and click Permanently Delete.
  2. Confirm that you no longer need the file and click OK.
Query the tasks of a recycle bin The NAS console allows you to view the tasks that are run in the previous seven days to restore or permanently delete files in a recycle bin. The NAS console can show up to 50 task records.
  1. On the Recycle Bin page, click Task Management.
  2. On the Task Management tab, view the data restoration or permanent deletion tasks that are complete.
Cancel a permanent deletion task or a data restoration task You can cancel a data restoration task or a permanent deletion task in the NAS console when the task is in the running state.
  • After you cancel a data restoration task, you can query the restored files in the file system and unrestored files in the recycle bin.
  • After you cancel a permanent deletion task, you cannot retrieve the files or directories that are permanently deleted by the task. However, you can still query the files or directories that are not permanently deleted from the recycle bin.
  1. On the Recycle Bin page, click Task Management.
  2. On the Task Management tab, find the task that you want to cancel and click Cancel.

FAQ