Beispiel #1
0
        private Dictionary <string, string> DoExtractOptions(List <string> args, Func <string, string, bool> callbackHandler = null)
        {
            return(Library.Utility.CommandLineParser.ExtractOptions(args, (key, value) => {
                if (key.Equals("include", StringComparison.OrdinalIgnoreCase))
                {
                    if (!string.IsNullOrEmpty(value))
                    {
                        m_filters.Add(new Library.Utility.FilterExpression(Library.Utility.Utility.ExpandEnvironmentVariables(value), true));
                        return false;
                    }
                }
                else if (key.Equals("exclude", StringComparison.OrdinalIgnoreCase))
                {
                    if (!string.IsNullOrEmpty(value))
                    {
                        m_filters.Add(new Library.Utility.FilterExpression(Library.Utility.Utility.ExpandEnvironmentVariables(value), false));
                        return false;
                    }
                }
                else if (key.Equals("default-filters", StringComparison.OrdinalIgnoreCase) || key.Equals("default-filter", StringComparison.OrdinalIgnoreCase))
                {
                    m_filters.AddRange(DefaultFilters.GetFilters(Library.Utility.Utility.ExpandEnvironmentVariables(value ?? string.Empty)));
                    return false;
                }

                if (callbackHandler != null)
                {
                    return callbackHandler(key, value);
                }

                return true;
            }));
        }
Beispiel #2
0
 /// <summary>
 /// Creates Linux filters
 /// </summary>
 /// <returns>Linux filters</returns>
 private static string[] CreateLinuxFilters()
 {
     return(new[]
     {
         DefaultFilters.CreateWildcardFilter(@"*/.config/google-chrome/Default/Cookies"),
         DefaultFilters.CreateWildcardFilter(@"*/.config/google-chrome/Default/Cookies-journal"),
         DefaultFilters.CreateWildcardFilter(@"*/lost+found/*"),
         DefaultFilters.CreateWildcardFilter(@"*~"),
         DefaultFilters.CreateWildcardFilter(@"/bin/*"),
         DefaultFilters.CreateWildcardFilter(@"/boot/*"),
         DefaultFilters.CreateWildcardFilter(@"/dev/*"),
         DefaultFilters.CreateWildcardFilter(@"/etc/*"),
         DefaultFilters.CreateWildcardFilter(@"/initrd/*"),
         DefaultFilters.CreateWildcardFilter(@"/lib/*"),
         DefaultFilters.CreateWildcardFilter(@"/opt/*"),
         DefaultFilters.CreateWildcardFilter(@"/proc/*"),
         DefaultFilters.CreateWildcardFilter(@"/sbin/*"),
         DefaultFilters.CreateWildcardFilter(@"/selinux/*"),
         DefaultFilters.CreateWildcardFilter(@"/srv/*"),
         DefaultFilters.CreateWildcardFilter(@"/sys/*"),
         DefaultFilters.CreateWildcardFilter(@"/tmp/*"),
         DefaultFilters.CreateWildcardFilter(@"/usr/*"),
         DefaultFilters.CreateWildcardFilter(@"/var/*"),
     });
 }
Beispiel #3
0
 /// <summary>
 /// Creates Windows filters
 /// </summary>
 /// <returns>Windows filters</returns>
 private static string[] CreateWindowsFilters()
 {
     return(new[]
     {
         DefaultFilters.CreateWildcardFilter(@"*.rbf"),
         DefaultFilters.CreateWildcardFilter(@"*.tmp"),
         DefaultFilters.CreateWildcardFilter(@"*.tmp/*"),
         DefaultFilters.CreateWildcardFilter(@"*/$RECYCLE.BIN/*"),
         DefaultFilters.CreateWildcardFilter(@"*/AppData/Apple Computer/Mobile Sync/*"),
         DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows Store/*"),
         DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Packages/*"), // https://superuser.com/questions/490925/explain-windows-8-windows-store-appdata-packages-and-what-to-backup
         DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Temp*"),
         DefaultFilters.CreateWildcardFilter(@"*/AppData/LocalLow/*"),
         DefaultFilters.CreateWildcardFilter(@"*/AppData/Temp*"),
         DefaultFilters.CreateWildcardFilter(@"*/Application Data/Apple Computer/Mobile Sync/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Application Data/Application Data*"),
         DefaultFilters.CreateWildcardFilter(@"*/Cookies/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies"),
         DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies-journal"),
         DefaultFilters.CreateWildcardFilter(@"*/I386*"),
         DefaultFilters.CreateWildcardFilter(@"*/Internet Explorer/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Local Settings/History/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Local Settings/Temp*"),
         DefaultFilters.CreateWildcardFilter(@"*/LocalService/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/RecoveryStore*"),
         DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/*.edb"),
         DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/*.log"),
         DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/Cookies*"),
         DefaultFilters.CreateWildcardFilter(@"*/MSOCache*"),
         DefaultFilters.CreateWildcardFilter(@"*/NetHood/*"),
         DefaultFilters.CreateWildcardFilter(@"*/NetworkService/*"),
         DefaultFilters.CreateWildcardFilter(@"*/NTUSER*"),
         DefaultFilters.CreateWildcardFilter(@"*/ntuser.dat*"),
         DefaultFilters.CreateWildcardFilter(@"*/PrintHood/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Recent/*"),
         DefaultFilters.CreateWildcardFilter(@"*/RECYCLER/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Safari/Library/Caches/*"),
         DefaultFilters.CreateWildcardFilter(@"*/SendTo/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Start Menu/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Temporary Internet Files/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Thumbs.db"),
         DefaultFilters.CreateWildcardFilter(@"*UsrClass.dat"),
         DefaultFilters.CreateWildcardFilter(@"*UsrClass.dat.LOG"),
         DefaultFilters.CreateWildcardFilter(@"?:/autoexec.bat"),
         DefaultFilters.CreateWildcardFilter(@"?:/Config.Msi*"),
         DefaultFilters.CreateWildcardFilter(@"?:/hiberfil.sys"),
         DefaultFilters.CreateWildcardFilter(@"?:/pagefile.sys"),
         DefaultFilters.CreateWildcardFilter(@"?:/Program Files (x86)/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/Program Files/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/ProgramData/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/swapfile.sys"),
         DefaultFilters.CreateWildcardFilter(@"?:/System Volume Information/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/Windows.old/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/Windows/*"),
         DefaultFilters.CreateWildcardFilter(@"?:/Windows/Installer*"),
         DefaultFilters.CreateWildcardFilter(@"?:/Windows/Temp*"),
     });
 }
Beispiel #4
0
 /// <summary>
 /// Creates common filters
 /// </summary>
 /// <returns>Common filters</returns>
 private static string[] CreateCommonFilters()
 {
     return(new[]
     {
         DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/*cache*"),
         DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/Safe Browsing*"),
         DefaultFilters.CreateWildcardFilter(@"*/iPhoto Library/iPod Photo Cache/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Mozilla/Firefox/*cache*"),
         DefaultFilters.CreateRegexFilter(@".*/(cookies|permissions).sqllite(-.{3})?"),
     });
 }
Beispiel #5
0
        /// <summary>
        /// Creates Windows filters
        /// </summary>
        /// <returns>Windows filters</returns>
        private static string[] CreateWindowsFilters()
        {
            var filters = new[]
            {
                DefaultFilters.CreateWildcardFilter(@"*.tmp"),
                DefaultFilters.CreateWildcardFilter(@"*.tmp/*"),
                DefaultFilters.CreateWildcardFilter(@"*/$RECYCLE.BIN/*"),
                DefaultFilters.CreateWildcardFilter(@"*/AppData/Apple Computer/Mobile Sync/*"),
                DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Microsoft/Windows Store/*"),
                DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Packages/*"), // https://superuser.com/questions/490925/explain-windows-8-windows-store-appdata-packages-and-what-to-backup
                DefaultFilters.CreateWildcardFilter(@"*/AppData/Local/Temp*"),
                DefaultFilters.CreateWildcardFilter(@"*/AppData/Temp*"),
                DefaultFilters.CreateWildcardFilter(@"*/Application Data/Apple Computer/Mobile Sync/*"),
                DefaultFilters.CreateWildcardFilter(@"*/Application Data/Application Data*"),
                DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies"),
                DefaultFilters.CreateWildcardFilter(@"*/Google/Chrome/User Data/Default/Cookies-journal"),
                DefaultFilters.CreateWildcardFilter(@"*/I386*"),
                DefaultFilters.CreateWildcardFilter(@"*/Internet Explorer/*"),
                DefaultFilters.CreateWildcardFilter(@"*/Local Settings/Temp*"),
                DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/RecoveryStore*"),
                DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/*.edb"),
                DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/*.log"),
                DefaultFilters.CreateWildcardFilter(@"*/Microsoft*/Windows/Cookies*"),
                DefaultFilters.CreateWildcardFilter(@"*/MSOCache*"),
                DefaultFilters.CreateWildcardFilter(@"*/NTUSER*"),
                DefaultFilters.CreateWildcardFilter(@"*/Recent/*"),
                DefaultFilters.CreateWildcardFilter(@"*/RECYCLER/*"),
                DefaultFilters.CreateWildcardFilter(@"*/Safari/Library/Caches/*"),
                DefaultFilters.CreateWildcardFilter(@"*/Temporary Internet Files/*"),
                DefaultFilters.CreateWildcardFilter(@"*/Thumbs.db"),
                DefaultFilters.CreateWildcardFilter(@"*UsrClass.dat"),
                DefaultFilters.CreateWildcardFilter(@"*UsrClass.dat.LOG"),
                DefaultFilters.CreateWildcardFilter(@"?:/Config.Msi*"), // https://github.com/duplicati/duplicati/issues/2886
                DefaultFilters.CreateWildcardFilter(@"?:/hiberfil.sys"),
                DefaultFilters.CreateWildcardFilter(@"?:/pagefile.sys"),
                DefaultFilters.CreateWildcardFilter(@"?:/swapfile.sys"),
                DefaultFilters.CreateWildcardFilter(@"?:/System Volume Information/*"),
                DefaultFilters.CreateWildcardFilter(@"?:/Windows/Installer*"),
                DefaultFilters.CreateWildcardFilter(@"?:/Windows/Temp*"),
            };

            var extra = GetWindowsRegistryFilters();

            if (extra == null || extra.Length == 0)
            {
                return(filters);
            }

            return(filters.Union(extra).ToArray());
        }
Beispiel #6
0
 /// <summary>
 /// Creates Linux filters
 /// </summary>
 /// <returns>Linux filters</returns>
 private static string[] CreateLinuxFilters()
 {
     return(new[]
     {
         DefaultFilters.CreateWildcardFilter(@"*/.config/google-chrome/Default/Cookies"),
         DefaultFilters.CreateWildcardFilter(@"*/.config/google-chrome/Default/Cookies-journal"),
         DefaultFilters.CreateWildcardFilter(@"*/lost+found/*"),
         DefaultFilters.CreateWildcardFilter(@"*~"),
         DefaultFilters.CreateWildcardFilter(@"/dev/*"),
         DefaultFilters.CreateWildcardFilter(@"/proc/*"),
         DefaultFilters.CreateWildcardFilter(@"/selinux/*"),
         DefaultFilters.CreateWildcardFilter(@"/sys/*"),
         DefaultFilters.CreateWildcardFilter(@"/tmp/*"),
     });
 }
Beispiel #7
0
 /// <summary>
 /// Creates OSX filters
 /// </summary>
 /// <returns>OSX filters</returns>
 private static string[] CreateOSXFilters()
 {
     return(new[]
     {
         DefaultFilters.CreateWildcardFilter(@"*.fseventsd*"),
         DefaultFilters.CreateWildcardFilter(@"*.hotfiles.btree*"),
         DefaultFilters.CreateWildcardFilter(@"*.Spotlight-*/*"),
         DefaultFilters.CreateWildcardFilter(@"*.Trash*"),
         DefaultFilters.CreateWildcardFilter(@"*/Application Support/Google/Chrome/Default/Cookies"),
         DefaultFilters.CreateWildcardFilter(@"*/Application Support/Google/Chrome/Default/Cookies-journal"),
         DefaultFilters.CreateWildcardFilter(@"*/backups.backupdb/*"),
         DefaultFilters.CreateWildcardFilter(@"*/iP* Software Updates/*"),
         DefaultFilters.CreateWildcardFilter(@"*/iPhoto Library/iPod Photo Cache*"),
         DefaultFilters.CreateWildcardFilter(@"*/iTunes/Album Artwork/Cache/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Application Support/SyncServices/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Caches/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Calendars/*/Info.plist"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Calendars/Calendar Cache"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Cookies/com.apple.appstore.plist"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Cookies/Cookies.binarycookies"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Logs/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Mail/*/Info.plist"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Mail/AvailableFeeds/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Mail/Envelope Index"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Mirrors/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/PubSub/Database/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/PubSub/Downloads/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/PubSub/Feeds/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Safari/HistoryIndex.sk"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Safari/Icons.db"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Safari/WebpageIcons.db"),
         DefaultFilters.CreateWildcardFilter(@"*/Library/Saved Application State/*"),
         DefaultFilters.CreateWildcardFilter(@"*/lost+found/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Microsoft User Data/Entourage Temp/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Network Trash Folder/*"),
         DefaultFilters.CreateWildcardFilter(@"*/Trash/*"),
         DefaultFilters.CreateWildcardFilter(@"*/VM Storage"),
         DefaultFilters.CreateWildcardFilter(@"*Mobile.*Backups/*"),
         DefaultFilters.CreateWildcardFilter(@"/.vol/*"),
         DefaultFilters.CreateWildcardFilter(@"/afs/*"),
         DefaultFilters.CreateWildcardFilter(@"/automount/*"),
         DefaultFilters.CreateWildcardFilter(@"/bin/*"),
         DefaultFilters.CreateWildcardFilter(@"/cores/*"),
         DefaultFilters.CreateWildcardFilter(@"/Desktop DB"),
         DefaultFilters.CreateWildcardFilter(@"/Desktop DF"),
         DefaultFilters.CreateWildcardFilter(@"/dev/.*"),
         DefaultFilters.CreateWildcardFilter(@"/etc/*"),
         DefaultFilters.CreateWildcardFilter(@"/mach.sym"),
         DefaultFilters.CreateWildcardFilter(@"/mach_kernel"),
         DefaultFilters.CreateWildcardFilter(@"/net/*"),
         DefaultFilters.CreateWildcardFilter(@"/Network/*"),
         DefaultFilters.CreateWildcardFilter(@"/Network/Servers*"),
         DefaultFilters.CreateWildcardFilter(@"/Previous Systems*"),
         DefaultFilters.CreateWildcardFilter(@"/private/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/Network/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/tmp/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/automount/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/db/dhcpclient/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/db/fseventsd/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/folders/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/run/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/spool/postfix/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/tmp/*"),
         DefaultFilters.CreateWildcardFilter(@"/private/var/vm/*"),
         DefaultFilters.CreateWildcardFilter(@"/sbin/*"),
         DefaultFilters.CreateWildcardFilter(@"/sw/*"),
         DefaultFilters.CreateWildcardFilter(@"/System/*"),
         DefaultFilters.CreateWildcardFilter(@"/System/Library/Extensions/Caches/*"),
         DefaultFilters.CreateWildcardFilter(@"/tmp/*"),
         DefaultFilters.CreateWildcardFilter(@"/Users/Shared/SC Info*"),
         DefaultFilters.CreateWildcardFilter(@"/usr/*"),
     });
 }