Skip to content

Instantly share code, notes, and snippets.

@dander
Created November 10, 2016 07:41
Show Gist options
  • Save dander/32b927b6e06867aebf1ae2a25856083e to your computer and use it in GitHub Desktop.
Save dander/32b927b6e06867aebf1ae2a25856083e to your computer and use it in GitHub Desktop.
search crashplan manifest (can be run in LINQPad in C# program mode)
void Main()
{
var result = ReadLines(@"D:\temp\crashplan\full-dump3.csv")
// faster initial tests...
// .Skip(1)
// .Take(10)
.Select(l => l.Split(','))
// extract properties of each csv row
.Select(l => new
{
Id = l[0],
ParentId = l[1],
// NOTE: paths may contain commas and they are not escaped, but this is the only column which does
Path = String.Join(",", l.Skip(3).Take(l.Length - 10)),
VersionTimestamp = l[l.Length - 7],
Size = l[l.Length - 5],
Checksum = l[l.Length - 4]
})
.Where(row => row.Size != "0")
// filter non-relevant noise
.Where(row => !row.Path.Contains("/Application Data/"))
.Where(row => !row.Path.Contains("/AppData/"))
.Where(row => !row.Path.Contains("/SkyDrive/"))
.Where(row => !row.Path.Contains("dave/."))
.Where(row => !row.Path.Contains("Dave/."))
// group entries by filename (grouping by checksum is also useful)
.GroupBy(row => row.Path.Split('/').Last())
// old backup location was on K
.Where(g => g.Any(row => row.Path.StartsWith("K")))
// new backup location is on D (find entries which were on K, but not on D)
.Where(g => !g.Any(row => row.Path.StartsWith("D")))
// sort by file path
.OrderBy(g => g.Select(item => item.Path).First())
.Dump();
}
public IEnumerable<string> ReadLines(string filename)
{
string line;
System.IO.StreamReader file = new System.IO.StreamReader(filename);
while((line = file.ReadLine()) != null)
{
yield return line;
}
file.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment