Commit 802acc75 authored by Michael Terry's avatar Michael Terry

Exclude snap cache dirs

parent 9bf4d1f9
......@@ -34,6 +34,7 @@
<item><p><file>~/.steam/root</file> <span its:translate="yes">(which by default also ignores <file its:translate="no">~/.local/share/Steam</file>)</span></p></item>
<item><p><file>~/.thumbnails</file></p></item>
<item><p><file>~/.xsession-errors</file></p></item>
<item><p><file>~/snap/*/*/.cache</file></p></item>
<item><p><file>/proc</file></p></item>
<item><p><file>/run</file></p></item>
<item><p><file>/sys</file></p></item>
......
......@@ -59,10 +59,8 @@ public class OperationBackup : Operation
var exclude_list = settings.get_file_list(EXCLUDE_LIST_KEY);
// Exclude directories no one wants to backup
var always_excluded = get_always_excluded_dirs();
foreach (string dir in always_excluded)
job.excludes.prepend(File.new_for_path(dir));
add_always_excluded_dirs(ref job.excludes, ref job.exclude_regexps);
foreach (File s in exclude_list)
job.excludes.prepend(s);
foreach (File s in include_list)
......@@ -84,17 +82,15 @@ public class OperationBackup : Operation
return null;
}
List<string> get_always_excluded_dirs()
void add_always_excluded_dirs(ref List<File> files, ref List<string> regexps)
{
List<string> rv = new List<string>();
// User doesn't care about cache
string dir = Environment.get_user_cache_dir();
if (dir != null) {
rv.append(dir);
files.prepend(File.new_for_path(dir));
// We also add our special cache dir because if the user still especially
// includes the cache dir, we still won't backup our own metadata.
rv.append(Path.build_filename(dir, Config.PACKAGE));
files.prepend(File.new_for_path(Path.build_filename(dir, Config.PACKAGE)));
}
// Likewise, user doesn't care about cache-like directories in $HOME.
......@@ -104,27 +100,26 @@ public class OperationBackup : Operation
// When changing this list, remember to update the help documentation too.
dir = Environment.get_home_dir();
if (dir != null) {
rv.append(Path.build_filename(dir, ".adobe/Flash_Player/AssetCache"));
rv.append(Path.build_filename(dir, ".ccache"));
rv.append(Path.build_filename(dir, ".gvfs"));
rv.append(Path.build_filename(dir, ".Private")); // encrypted copies of stuff in $HOME
rv.append(Path.build_filename(dir, ".recent-applications.xbel"));
rv.append(Path.build_filename(dir, ".recently-used.xbel"));
rv.append(Path.build_filename(dir, ".steam/root"));
rv.append(Path.build_filename(dir, ".thumbnails"));
rv.append(Path.build_filename(dir, ".xsession-errors"));
files.prepend(File.new_for_path(Path.build_filename(dir, ".adobe/Flash_Player/AssetCache")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".ccache")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".gvfs")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".Private"))); // encrypted copies of stuff in $HOME
files.prepend(File.new_for_path(Path.build_filename(dir, ".recent-applications.xbel")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".recently-used.xbel")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".steam/root")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".thumbnails")));
files.prepend(File.new_for_path(Path.build_filename(dir, ".xsession-errors")));
regexps.prepend(Path.build_filename(dir, "snap/*/*/.cache"));
}
// Skip all of our temporary directories
foreach (var tempdir in DejaDup.get_tempdirs())
rv.append(tempdir);
files.prepend(File.new_for_path(tempdir));
// Skip transient directories
rv.append("/proc");
rv.append("/run");
rv.append("/sys");
return rv;
files.prepend(File.new_for_path("/proc"));
files.prepend(File.new_for_path("/run"));
files.prepend(File.new_for_path("/sys"));
}
void fill_metadir() throws Error
......
......@@ -65,6 +65,7 @@ public abstract class ToolJob : Object
public List<File> includes; // BACKUP
public List<File> excludes; // BACKUP
public List<string> exclude_regexps; // BACKUP
protected List<File> _restore_files;
public List<File> restore_files { // RESTORE
......
......@@ -191,7 +191,9 @@ string default_args(BackupRunner br, Mode mode = Mode.NONE, bool encrypted = fal
args += "collection-status ";
if (mode == Mode.STATUS || mode == Mode.NONE || mode == Mode.DRY || mode == Mode.BACKUP) {
args += "'--exclude=%s' '--include=%s/deja-dup/metadata' ".printf(backupdir, cachedir);
args += "'--exclude=%s' ".printf(backupdir);
args += "'--exclude=%s/snap/*/*/.cache' ".printf(Environment.get_home_dir());
args += "'--include=%s/deja-dup/metadata' ".printf(cachedir);
string[] excludes1 = {"~/Downloads", "~/.local/share/Trash", "~/.xsession-errors", "~/.thumbnails", "~/.steam/root", "~/.Private", "~/.gvfs", "~/.ccache", "~/.adobe/Flash_Player/AssetCache"};
foreach (string ex in excludes1) {
......
......@@ -310,6 +310,12 @@ internal class DuplicityJob : DejaDup.ToolJob
includes.sort((CompareFunc)cmp_prefix);
excludes.sort((CompareFunc)cmp_prefix);
// TODO: Figure out a more reasonable way to order regexps and files.
// For now, just stick them in the front.
foreach (string r in exclude_regexps) {
saved_argv.append("--exclude=" + r);
}
foreach (File i in includes) {
var excludes2 = excludes.copy();
foreach (File e in excludes2) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment