Sobes.tech
Junior — Middle

How can lost data be recovered on a Linux server?

sobes.tech AI

Answer from AI

There are several approaches to recover lost data on a Linux server:

  1. Check the trash and temporary files — if the data was deleted via the graphical interface, it might be in the trash.

  2. Use file recovery utilities:

    • extundelete — for recovering files on ext3/ext4 file system partitions.
    • testdisk and photorec — powerful tools for recovering deleted files and partitions.
  3. Restore from backups — if backup systems are configured (e.g., using rsync, tar, Bacula), data can be restored from backups.

  4. Use journaling file systems — if a journaling file system is used, it may be possible to recover data from the journal.

  5. Monitoring and preventing further writing — it is crucial to stop writing to the disk as soon as possible to avoid overwriting the deleted data.

Example of using extundelete to recover a file:

sudo extundelete /dev/sdX --restore-file path/to/deleted/file

where /dev/sdX is the device with the relevant partition, and path/to/deleted/file is the path to the deleted file relative to the root of the partition.

How can lost data be recovered on a Linux server… - sobes.tech