How can operation and maintenance personnel effectively prevent accidental deletion of data? Linux learning!

  Data is very important to website administrators and enterprises. The accidental deletion and loss of data in life is very common, and it also causes us a lot of trouble. So how can operation and maintenance personnel effectively prevent accidental deletion of data?

  Tips to effectively prevent accidental deletion of data:

  1. Make sure to back up before modifying or deleting data. It's better to have a different machine backup, modify the configuration, etc., first submit to the version management system before publishing it online.

  2. New users of operation and maintenance should use the mv command to replace the rm command. Do not delete useless files in a hurry, but move them to the recycle bin/tmp for observation for a period of time.

  You can block rm by setting aliases and other means, so that once you use the rm command directly, you will be aware (of course, I really want to use a means to bypass the alias).

  3. If you have to delete data, you can also use find combined with rm to replace simple rm, including setting timed tasks and other actions to perform cleanup.

  4. If you have to use rm to delete, please try to switch the directory and delete the data in the directory first. If you don't need wildcards, you don't need wildcards.

  E.g:

  1 [root@oldboy /]# cd /oldboy/

  2[root@oldboy /]# rm -f test1 test2

  5. If you have to use rm to delete and use wildcards, please follow the method below:

  1[root@oldboy /]# cd /oldboy/

  2[root@oldboy oldboy]# rm -fr * #Do not include "/" in the target.

  6. It should be prohibited to delete using commands similar to rm -fr /oldboy/*

  a. In this command, if there are more spaces before and after any slash in the target path, it may bring disaster.

  1 [root@oldboy /]# rm -fr /oldboy/*

  2 For example: rm -fr /oldboy/ *, if there is a space before *, all contents in the current directory will be deleted.

  3[root@oldboy /]# rm -fr /oldboy/ * # will delete all the roots of the current directory.

  4[root@oldboy /]# rm -fr /oldboy/ *

  7. If you must delete the rm -fr /oldboy/* command, the last way to avoid mistakes is to use the tab key to complete, do not type any characters by hand to prevent accidental deletion

  8. If you are not deleting a directory, don't use rm -fr, just use the most down-scaling method rm -f, even for a small number of important files, you don't need -f to get a confirmation delete prompt message.

  9. Additional supplements, use rsync --delete with caution


Guess you like

Origin blog.51cto.com/15052541/2678317