Permalink
Browse files

list files command: show deleted files

until now, the "list files jobid=" command did
simply show the files that were backed up in a certain
jobid.

As in accurate mode, the files are send by the fd as "backed up" but marked as
deleted (FT_DELETED). This information is then stored in the database by setting the
fileindex of that file as 0.

With this patch, the deleted files are visible as such in the output of
"list files jobid=" as the following output shows.

First a backup was done of a small test fileset:

*list files jobid=1
 /testdata/testdir/testfile
 /testdata/testdir/
 /testdata/testdir2/
 /testdata/testdir2/testfile2
 /testdata/

then, testdir2 and its content was deleted before running the
second incremental backup:

*list files jobid=2
 /testdata/testdir2/ (deleted)
 /testdata/testdir2/testfile2 (deleted)
 /testdata/

The output of the command shows that both the directory and the file
have been detected as missing and marked as deleted by appending a

       "(deleted)"

after the file/directory name
  • Loading branch information...
pstorz committed Apr 7, 2017
1 parent f462a24 commit 248ae67f561a02eb607028e324484e66fb6c9d87
Showing with 9 additions and 7 deletions.
  1. +9 −7 src/cats/sql_list.c
View
@@ -582,10 +582,11 @@ void B_DB::list_files_for_job(JCR *jcr, JobId_t jobid, OUTPUT_FORMATTER *sendit)
* Stupid MySQL is NON-STANDARD !
*/
if (get_type_index() == SQL_TYPE_MYSQL) {
- Mmsg(cmd, "SELECT CONCAT(Path.Path,Filename.Name) AS Filename "
- "FROM (SELECT PathId, FilenameId FROM File WHERE JobId=%s "
+ Mmsg(cmd, "SELECT CONCAT(Path.Path,Filename.Name) AS Filename, "
+ "CASE WHEN F.FileIndex = '0' THEN '(deleted)' ELSE '' END status "
+ "FROM (SELECT PathId, FilenameId, FileIndex FROM File WHERE JobId=%s "
"UNION ALL "
- "SELECT PathId, FilenameId "
+ "SELECT PathId, FilenameId, '0' "
"FROM BaseFiles JOIN File "
"ON (BaseFiles.FileId = File.FileId) "
"WHERE BaseFiles.JobId = %s"
@@ -594,14 +595,15 @@ void B_DB::list_files_for_job(JCR *jcr, JobId_t jobid, OUTPUT_FORMATTER *sendit)
"AND Path.PathId=F.PathId",
edit_int64(jobid, ed1), ed1);
} else {
- Mmsg(cmd, "SELECT Path.Path||Filename.Name AS Filename "
- "FROM (SELECT PathId, FilenameId FROM File WHERE JobId=%s "
+ Mmsg(cmd, "SELECT Path.Path||Filename.Name AS Filename , "
+ "CASE WHEN F.FileIndex = '0' THEN '(deleted)' ELSE '' END status "
+ "FROM (SELECT PathId, FilenameId, FileIndex FROM File WHERE JobId=%s "
"UNION ALL "
- "SELECT PathId, FilenameId "
+ "SELECT PathId, FilenameId , '0' "
"FROM BaseFiles JOIN File "
"ON (BaseFiles.FileId = File.FileId) "
"WHERE BaseFiles.JobId = %s"
- ") AS F, Filename,Path "
+ ") AS F, Filename, Path "
"WHERE Filename.FilenameId=F.FilenameId "
"AND Path.PathId=F.PathId",
edit_int64(jobid, ed1), ed1);

0 comments on commit 248ae67

Please sign in to comment.