Backup Exclusion Issue: Specific Directories root drive

I’m having an issue with setting up exclusions in my backup configuration and would appreciate any assistance. My root directory for the backup is located at D:\
I want to exclude everything from the backup except for the following directories and their subdirectories:

D:\Backup\OLD
D:\Sys\Docs
D:\Data\bd

There are multiple files and folders at the root of D:\, as well as within subdirectories, that I want to exclude. For example, I want to exclude files like D:\Backup\list.txt and folders like D:\Sys\Docs_old.

I attempted to configure the exclusions as follows:

*
!**/Backup/OLD/**
!**/Sys/Docs/**
!**/Data/bd/**

However, this doesn’t seem to be working as intended. Does anyone have a solution or suggestion for correctly setting up these exclusions? Thank you in advance for your help.

Something like this should work:

/*
!/Backup/
/Backup/*
!/Backup/OLD
/Sys/*
!/Sys/Docs
/Data/*
!/Data/bd

Hello and thank you for the example.
I have a problem when i apply your method:

My root is on a network :
\192.168.1.10\c$

and so I apply the pattern :
but it doesn’t work, I just have the Pictures folder and subfolder.
I should normally have his file and sub-file: Desktop, Documents, Pictures and Gest Station CA

/*
!/Users/
/Users/*
!/Users/stationcast

!/Users/stationcast/
/Users/stationcast/*
!/Users/stationcast/Desktop

!/Users/stationcast/
/Users/stationcast/*
!/Users/stationcast/Documents

!/Users/stationcast/
/Users/stationcast/*
!/Users/stationcast/Pictures

!/ProgramData/
/ProgramData/*
!/ProgramData/Gest Station CA

I have the authorizations, because I access them via the explorer.
Thank you for your help.

IMO exclude model used by kopia is not very user friendly if you want to include only specific items.

If you struggle with these rules, given that you have only 4 folders to backup simply create separate snapshots for Desktop, Documents, Pictures and Gest Station CA

you can always snapshot them all later in one go by running:

kopia snapshot create --all

FYI - this is how I ended up using it as β€œinclude” rules wizardry drove me mad.

I wish somebody creates --include flag one day

Have had a moment now and made exclusion rules to work.

Source:

$ tree .
.
β”œβ”€β”€ A
β”‚   β”œβ”€β”€ AA
β”‚   β”‚   └── testAA.txt
β”‚   β”œβ”€β”€ AB
β”‚   β”‚   β”œβ”€β”€ ABA
β”‚   β”‚   β”‚   └── testABA.txt
β”‚   β”‚   β”œβ”€β”€ ABB
β”‚   β”‚   β”‚   └── testABB.txt
β”‚   β”‚   β”œβ”€β”€ ABC
β”‚   β”‚   β”‚   └── testABC.txt
β”‚   β”‚   └── testAB.txt
β”‚   β”œβ”€β”€ AC
β”‚   β”‚   └── testAC.txt
β”‚   β”œβ”€β”€ AD
β”‚   β”‚   β”œβ”€β”€ ADA
β”‚   β”‚   β”‚   └── testADA.txt
β”‚   β”‚   └── testAD.txt
β”‚   └── testA.txt
β”œβ”€β”€ B
β”‚   └── testB.txt
β”œβ”€β”€ C
β”‚   └── testC.txt
β”œβ”€β”€ D
β”‚   β”œβ”€β”€ DA
β”‚   β”‚   └── testDA.txt
β”‚   β”œβ”€β”€ DB
β”‚   β”‚   └── testDB.txt
β”‚   β”œβ”€β”€ DC
β”‚   β”‚   └── testDC.txt
β”‚   └── testD.txt
└── test.txt

To include only below directories (and exclude anything else):

/A/AB/ABB
/A/AB/ABC
/D/DC

this exclusion rules work:

/*
!/A
/A/*
!/A/AB
/A/AB/*
!/A/AB/ABB
!/A/AB/ABC

!/D
/D/*
!/D/DC

I have tested and it works as intended.

$ kopia ls -l kea16302460cffae2e339c05122feede5
drwxr-xr-x            0 2023-11-14 18:44:03 GMT k5e96c2e68004633da2a39ea19d7a6bb6  A/
drwxr-xr-x            7 2023-11-14 18:29:49 GMT kf82a77068c7625d4cda87b4be52b4aba  D/

$ kopia ls -l kea16302460cffae2e339c05122feede5/A
drwxr-xr-x            0 2023-11-14 18:44:03 GMT kbd1de7df14378fe99d90bce8b9517cb4  AB/

$ kopia  ls -l kea16302460cffae2e339c05122feede5/A/AB
drwxr-xr-x            0 2023-11-14 18:20:48 GMT k5773e11290dd5606f3361c03b7d9f7ae  ABB/
drwxr-xr-x            0 2023-11-14 18:20:48 GMT kd2fc526858045a45c6c489a3ff1cc4b6  ABC/

$ kopia  ls -l kea16302460cffae2e339c05122feede5/A/AB/ABB
-rw-r--r--            0 2023-11-14 18:20:48 GMT 1a90f48029f40abc714853d2e82742d9   testABB.txt

$ kopia ls -l kea16302460cffae2e339c05122feede5/A/AB/ABC
-rw-r--r--            0 2023-11-14 18:20:48 GMT 1a90f48029f40abc714853d2e82742d9   testABC.txt

$ kopia ls -l kea16302460cffae2e339c05122feede5/D
drwxr-xr-x            7 2023-11-08 15:17:32 GMT k06cbd9dea4c9ab77b0b829b9d92d6139  DC/

$ kopia ls -l kea16302460cffae2e339c05122feede5/D/DC
-rw-r--r--            7 2023-11-08 15:17:32 GMT ae8906c1c3f5b7db37b682ea7cfc80ff   testDC.txt

thank you, it’s fantastic, I’ll be able to save my files :slight_smile:

1 Like