Media Hub X Website Data Deletion Instructions
Website Data Deletion Instructions
Updated on 2025.05.09
1. Introduction
During the operation of a website, data may need to be deleted for various reasons, such as website revision, business adjustments, compliance requirements for data, or server space cleanup. However, data deletion operations involve the normal operation of the website and data security, and should be treated with caution. This instruction aims to provide you with detailed information about website data deletion, the operation process, and precautions, helping you to complete the data deletion task safely and effectively.
2. Types of Data Deletion and Applicable Scenarios
2.1 Total Data Deletion
Applicable Scenarios
- Website Suspension or Closure: When deciding to stop operating the website and no longer provide relevant services, all website data, including website files, database data, log files, etc., needs to be deleted to release server resources and avoid potential data risks.
- Server Reset or Replacement: When planning a large-scale system reset of the server or replacing the server without wanting the old data to be migrated to the new environment, all data can be deleted to ensure a clean and redundant-data-free new server environment.
Impact
- Complete Loss of Website Functionality: After deleting all data, the website will not be accessible or usable, and all pages, functions, and user interaction information will disappear.
- Data Cannot Be Recovered: If there is no prior backup, the deleted data will be permanently lost, which may have a serious impact on the business, such as the loss of user information, business transaction records, etc.
2.2 Partial Data Deletion
Applicable Scenarios
- Expired or Useless Data: For example, if there are old articles that have not been updated for a long time and expired activity information on the website, these expired or useless data can be deleted to optimize website data storage and improve website operation efficiency.
- User Data Cleanup: According to user requests or data protection regulations, personal information and related data of specific users need to be deleted to protect user privacy.
- Adjustment of Specific Business Data: When the business process changes, some data generated by certain business modules may no longer be needed. For example, when a product is phased out, relevant product introduction, order data, etc., can be deleted.
Impact
- Partial Functionality Affected: Deleting partial data may cause some functions of the website that rely on this data to not work properly. For example, after deleting product data, the product display page may have vacancies or error prompts.
- Certain Impact on Business Continuity: If key business data is deleted, it may affect the continuity of relevant business processes, and corresponding adjustments need to be made after prior evaluation.
3. Preparation Work Before Data Deletion
3.1 Data Backup
- Importance: Before any data deletion operation, a comprehensive backup of important data must be carried out. Backing up data is a key safeguard to prevent misoperations or the need to restore data later, avoiding irreparable losses caused by data deletion.
Backup Methods
- Website File Backup: FTP (File Transfer Protocol) tools can be used to download all files in the website root directory (including HTML, CSS, JavaScript, images, videos, and other types of files) to a local computer or other external storage devices. You can also use command-line tools (such as rsync, scp, etc.) on the server to copy the files to a secure storage location, such as a backup server or cloud storage service.
- Database Backup: Select the corresponding backup method according to the type of database used by the website. If using a MySQL database, you can export the database through phpMyAdmin (a Web-based MySQL database management tool); you can also use the mysqldump command in the command line to backup the database. For other databases, such as PostgreSQL, MongoDB, etc., there are corresponding backup tools and commands.
- Configuration File Backup: Server and website application configuration files contain important operation parameters and settings information, which also need to be backed up. These files are usually located in the /etc directory of the server, such as the configuration files httpd.conf or nginx.conf of the Web server (Apache or Nginx). You can copy the files to a secure location for backup.
- Backup Verification: After completing the data backup, it is recommended to verify the backup data to ensure its integrity and usability. You can try to restore some data from the backup files and check whether the data is correctly restored to avoid problems with the backup data that prevent normal restoration when needed.
3.2 Determine the Deletion Scope
- Identify Data Types: Carefully sort out the types of data stored on the server, including user-uploaded files (such as images, documents, videos, etc.), database records (various data stored in databases such as MySQL, PostgreSQL), log files (recording server operation activities, user access, etc.), temporary files (temporary data generated by server software or scripts), and configuration files.
- Define the Deletion Boundaries: According to the purpose of data deletion, determine the specific deletion scope. If you want to delete the data of a specific user, you need to clarify all the data storage locations and associated data related to that user; if you are cleaning up expired data, you need to determine the time range of the expired data and find all the data that meets that range. When determining the deletion scope, be sure to be cautious and accurate to avoid mistakenly deleting important data.
3.3 Permission Confirmation
- Operation Permission Check: Ensure that the personnel performing the data deletion operation have sufficient permissions. In the server system, different users have different permission levels. Only users with administrator permissions or those granted specific data deletion permissions can perform relevant deletion operations. If the permissions are insufficient, the data deletion task cannot be completed, and it may even cause permission errors that lead to other problems.
- Permission Management: For servers and websites managed by multiple people, a reasonable permission management mechanism should be established. Clearly define which personnel can perform data deletion operations and the specific data scope and permission levels they can operate on. At the same time, record the allocation and change of permissions for traceability and auditing.
4. Specific Operation Process of Data Deletion
4.1 Website File Deletion
- Connect to the Server: Use an SSH (Secure Shell) tool to establish a connection to the server by entering the server address, username, and password. SSH is a secure remote connection protocol that allows command-line operations on the server.
- Locate the Website File Directory: Navigate to the directory storing the website files through the command line. Common website file storage directories include /var/www/html/ (suitable for Apache or Nginx Web servers on many Linux servers), /home/username/public_html/ (where username is the username of the website user). You can use the cd command to switch directories, for example: cd /var/www/html/.
- Delete Files: After confirming that you have located the correct website file directory, use the rm command to delete the files. If you want to delete all files and subdirectories under the directory, you can execute the rm -r * command. However, special attention should be paid that this command will recursively delete all contents under the directory. Once executed, the data cannot be recovered, so make sure it is the correct deletion directory before execution.
4.2 Database Data Deletion
- Connect to the Database: Select the corresponding database management tool or command-line client to connect according to the type of database used by the website. If using a MySQL database, you can connect to the MySQL database by entering mysql -u username -p (where username is the database username, and you will be prompted to enter the password after executing the command) in the command line; if using phpMyAdmin to manage the MySQL database, you can enter the access address of phpMyAdmin in the browser and log in by entering the username and password. For a PostgreSQL database, you can use the psql command-line tool to connect; for a MongoDB database, you can use the mongo shell to connect.
- Select the Database to Operate On: After connecting to the database management tool or client, select the specific database used by the website. In MySQL, you can use the use database_name command (where database_name is the name of the database) to switch to the target database; in phpMyAdmin, find and click the database to be operated on in the interface.
Delete Database Records
- Delete All Records: If you want to delete all records in a database table, in MySQL, you can use the TRUNCATE TABLE table_name; statement (where table_name is the name of the table to be emptied). This statement will quickly delete all data in the table and reset the auto-increment primary key. However, it should be noted that the TRUNCATE operation cannot be rolled back, and careful confirmation is required before execution.
- Delete Specific Records: If you only need to delete records that meet specific conditions, you can use the DELETE FROM table_name WHERE condition; statement (where condition is the deletion condition). For example, to delete user records in the user table where the age is greater than 60, you can use the DELETE FROM users WHERE age > 60; statement. When executing the DELETE statement, it is recommended to query and confirm whether the data to be deleted meets the expectations through the SELECT statement to avoid mistakenly deleting data.
4.3 Log File Deletion
- Locate the Log File Directory: Log files are usually stored in specific directories on the server. Common log file directories include /var/log/ (storing system logs, Web server logs, etc.), /home/username/logs/ (where username is the username of the website user, and application logs related to that user can be stored). Use the command-line tool and switch to the log file directory through the cd command, for example: cd /var/log/.
- Delete Log Files: After determining the log file directory, you can use the rm command to delete the log files. If you want to delete all log files under the directory, you can execute the rm -r * command. However, it should be noted that some log files may be in use by the system, and directly deleting them may cause system exceptions. For log files in use, you can stop the relevant services first and then perform the deletion operation; or use the cat /dev/null > logfile command (where logfile is the name of the log file) to empty the content of the log file without deleting the file itself, which can preserve the file structure and avoid affecting the normal operation of the system.
4.4 Temporary File Deletion
- Find the Temporary File Directory: Temporary files are usually stored in the /tmp directory of the server, and different server software and applications may generate temporary files in other specific directories. You can determine the storage location of temporary files by looking up the configuration files or documentation of the relevant software.
- Delete Temporary Files: After finding the temporary file directory, use the rm command to delete the temporary files. If you want to delete all files and subdirectories under the /tmp directory, you can execute the rm -rf /tmp/ command. Since temporary files are usually generated temporarily by the system or application, deleting these files generally will not affect the normal operation of the system and application. However, it is still recommended to confirm before deletion to avoid mistakenly deleting important temporary data.
5. Verification and Follow-up Processing After Data Deletion
5.1 Data Deletion Verification
- File System Verification: After completing the file deletion operation, use the ls command to view the file directory and confirm that the files and directories to be deleted no longer exist. If there are residual files, you need to check whether the deletion operation was executed correctly and whether there are issues such as insufficient permissions.
- Database Verification: In the database, use query statements to check whether the relevant data in the table has been successfully deleted. For example, in MySQL, execute the SELECT statement to query the table from which the data was supposed to be deleted and confirm that there is no data that meets the deletion condition. If there is still residual data, you need to check whether the deletion statement is correct or whether there are situations such as uncommitted transactions.
- Log Verification: Check the server log files to confirm whether there are error messages recorded during the data deletion operation. If errors are found, troubleshoot and fix them according to the error prompts to ensure the integrity and correctness of the data deletion operation.
5.2 Cache Clearance
- Server Cache Clearance: If the server uses a caching mechanism (such as Web server cache, application cache, etc.), after data deletion, the cache needs to be cleared to ensure that new requests can obtain the latest data. For an Nginx server, you can clear the cache by deleting the files in the cache directory (usually /var/cache/nginx/) and execute the rm -rf /var/cache/nginx/* command; for other cache systems, such as Memcached, Redis, etc., you can use the corresponding commands or management tools to clear the cache.
- Browser Cache Clearance: Inform website users that if abnormal website display (such as still showing the deleted data) is found after data deletion, it may be caused by the browser cache. It is recommended that users clear the browser cache. The cache clearance methods vary slightly for different browsers. For example, in the Chrome browser, you can click "More Tools" in the browser menu, select "Clear Browsing Data", and then select the range of cache data to be cleared for clearance; in the Firefox browser, you can click "Clear Data" in the "Privacy & Security" settings to clear the cache.
5.3 Notify Relevant Personnel
- Internal Team Notification: Notify the website development team, operation and maintenance team, business team, and other internal relevant personnel of the data deletion operation and its results, inform them of the scope, time, and possible impacts of the data deletion, so that they can make corresponding business adjustments and system maintenance work.
- User Notification (if necessary): If the data deletion operation involves user data or may have a significant impact on users' use of the website, users should be notified in a timely manner in accordance with relevant laws, regulations, and user agreements. The notification content should include the reasons, scope, impacts on users, and users' rights and response measures of the data deletion. Notification methods can include website announcements, emails, in-site messages, etc.
6. Precautions and Risk Prevention
6.1 Operate with Caution
- Avoid Mistaken Deletion: Data deletion operations are irreversible. Before any deletion operation, carefully check the deletion scope, deletion conditions, and other information to ensure the accuracy of the operation. It is recommended to conduct simulated operations in a test environment before the formal execution of the deletion operation to familiarize yourself with the operation process and effects and reduce the risk of mistaken deletion.
- Follow the Operation Specifications: Strictly follow the operation process and methods described in this instruction and relevant technical documents. Different server systems, database types, and software environments may have differences. Using inappropriate operation methods may lead to data loss or system failures.
6.2 Permission Management
- Principle of Minimum Privilege: When allocating data deletion permissions, follow the principle of minimum privilege and only grant the minimum permissions required for the data deletion operation. Avoid too many people having excessive data deletion permissions to reduce the possibility of data security risks caused by misoperations or malicious operations by personnel.
- Permission Change Record: Record in detail the allocation and change of data deletion permissions, including the time of permission grant, the object of permission grant, the scope of permission, and the reasons for the change. The record can be used for traceability and auditing, and can quickly locate the responsibilities and causes when data security problems occur.
6.3 Data Recovery Plan
- Formulate a Recovery Plan: Although a backup has been made before data deletion, a detailed data recovery plan still needs to be formulated, clearly defining the operation process and responsible persons when data needs to be recovered. The recovery plan should include where to obtain the backup data, how to perform the data recovery operation, and verification and testing steps during the recovery process.
- Regular Drills: Conduct regular data recovery drills and simulate the data recovery operation according to the recovery plan in case of data loss or damage. Through the drills, test the feasibility and effectiveness of the recovery plan, discover and solve problems that may occur during the recovery process, and ensure that the recovery work can be completed quickly and accurately when data recovery is actually needed.