Undelete command Tip: How to change restore location ?

Undelete command by default restores any file in /tmp location.

However suppose the file which you are trying to restore has more size and it is not possible to restore under /tmp.

In this case, we can mention another path for restore using below tip.

1. Create new directory where you want to restore, or choose a path.

[root@ngelinux ~]# mkdir /saket
[root@ngelinux ~]# 

 

2. Mention the restore path/directory under the text file /usr/nglinux/restorelocation.txt.

[root@ngelinux ~]# cat /usr/nglinux/restorelocation.txt 
/saket

 

3. Now run undelete command and see the magic.

[root@ngelinux ~]# undelete 
Starting now:
Enter the file name to search in Database for restore, or press enter to view all files ? 

Enter the file name to search in Database for restore, or press enter to view all files ? 
file
Searching filenames containing the string file ....


Following files are found:
1. /root/testfile1 deleted on 18-Apr-2019 at 15:24:02 of size 4 KB
2. /root/removedir1/file1 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
3. /root/removedir1/file2 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
4. /root/removedir1/file3 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
5. /root/removedir1/file4 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
Enter the number of file which you want to try to restore or press Ctrl+C to exit ?
2

1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.000184613 s, 22.2 MB/s
File file1 restored at /saket/file1... check if the contents are fine... else the data is over-written

[root@ngelinux ~]# cat /saket/file1 
hello
[root@ngelinux ~]# 

 

4. Remove the directory and now again the files gets restored in /tmp.

[root@ngelinux ~]# rm -rf /saket/
[root@ngelinux ~]# 

[root@ngelinux ~]# undelete 
Starting now:
Enter the file name to search in Database for restore, or press enter to view all files ? 
file
Searching filenames containing the string file ....


Following files are found:
1. /root/testfile1 deleted on 18-Apr-2019 at 15:24:02 of size 4 KB
2. /root/removedir1/file1 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
3. /root/removedir1/file2 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
4. /root/removedir1/file3 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
5. /root/removedir1/file4 deleted on 18-Apr-2019 at 15:26:01 of size 4 KB
Enter the number of file which you want to try to restore or press Ctrl+C to exit ?
5

1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.000302024 s, 13.6 MB/s
File file4 restored at /tmp/file4... check if the contents are fine... else the data is over-written

[root@ngelinux ~]# cat /tmp/file4 
hello
[root@ngelinux ~]#