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

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, 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 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 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:

  1. Log on to the NAS console.
  2. In the left-side navigation pane, choose File System > File System List.
  3. In the top navigation bar, select a region.
  4. On the File System List page, click the ID of the file system that you want to manage.
  5. On the details page of the file system, click Recycle Bin and then click Enable Recycle Bin.
  6. 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 that you specify. 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 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:

  1. Log on to the NAS console.
  2. In the left-side navigation pane, choose File System > File System List.
  3. In the top navigation bar, select a region.
  4. On the File System List page, click the ID of the file system that you want to manage.
  5. On the details page of the file system, click Recycle Bin.
  6. On the Recycle Bin page, find the file that you want to restore and click Restore.
  7. 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

OperationDescriptionProcedure
Empty the recycle binIf 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.
  1. On the Recycle Bin page, click Empty Recycle Bin.
  2. Confirm that you no longer need the files in the recycle bin. Click OK.
Change the retention period of filesYou 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 the recycle binAfter 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
  • If you disable the recycle bin, all files in the recycle bin are permanently deleted.
  • If you disable and then enable the 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 that you no longer want to use the recycle bin feature. Click OK.
Query files in the recycle binYou 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 binIf 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.
  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 the recycle binIn 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.
  1. On the Recycle Bin page, click Task Management.
  2. On the Task Management tab, view the completed data restoration tasks or permanent deletion tasks.
Cancel a permanent deletion task or a data restoration taskIf a data restoration task or a permanent deletion task is in the Running state, you can cancel the task in the NAS console.
  • After you cancel a data restoration task, you can query the restored files in the file system and query the 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 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