How to backup office files

I want to backup all office files and the newly created later in one folder and exclude all other types
How to write the exclude file ?
Thank you.

1 Like

my test data folder tree is below

D:\RESTIC-TEST\DATA
โ”‚   ๆ™บ่ƒฝๅŒน้…็ณป็ปŸV3.pdf
โ”‚
โ”œโ”€โ”€โ”€1
โ”‚       winserv.exe
โ”‚
โ”œโ”€โ”€โ”€2
โ”‚   โ”‚   winserv.exe
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€โ”€2-1
โ”‚   โ”‚       ้˜ฟ้‡Œoss.txt
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€โ”€2-2
โ”‚   โ”‚       2021-08-25.log
โ”‚   โ”‚       2021-08-30.log
โ”‚   โ”‚       CACHEDIR.TAG
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€โ”€2-3
โ”‚           ๅผ‚ๆญฅๆถˆๆฏๆŽจ้€้…็ฝฎ่กจ.xlsx
โ”‚
โ””โ”€โ”€โ”€3
        members.json
        WeChat Image_20200722150945.jpg
        ๆผๅ•ๆ—ฅๅฟ—.zip

my restic backup command is
restic -r repo -p key backup --exclude-caches --iexclude-file exclude.txt --files-from file.txt -n -vvv

my file.txt content is

D:/restic-test/data/*.pdf
D:\restic-test\data\2\2-3\*.xlsx

Is it possible to make include file supports walk recursively? so just this line will include all excel file
D:/restic-test/data/**/*.xls[xm]

1 Like

Hi @kuyagic and welcome to the restic community! :slight_smile:

Thanks for the detailed report. Just making sure you havenโ€™t missed this, have you seen the documentation around excluding files?
If not give this a read and see if the information there provides enough information to solve your problem.
https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files

:wave:

1 Like

โ€ฆ got same Problem - but in my case only SumatraPDF Files, so I try this:
(I like to use AkelPad to generate a Text-File in UTF-8 Coded)

# OnlySumatraFiles.txt:
## First exclude all Windows-Drive-Letters:
/A/*
/B/*
/C/*
/D/*
/E/*
/F/*
/G/*
/H/*
/I/*
/J/*
/K/*
/L/*
/M/*
/N/*
/O/*
/P/*
/Q/*
/R/*
/S/*
/T/*
/U/*
/V/*
/W/*
/X/*
/Y/*
/Z/*
## Than re-include the wanted File-Types:
!**/*.PDF
!**/*.EPUB
!**/*.MOBI
!**/*.CHM
!**/*.XPS
!**/*.DjVu
!**/*.CBZ
!**/*.CBR
!**/*.JPG
!**/*.JPEG
!**/*.GIF
!**/*.PNG
!**/*.BMP
!**/*.TGA
!**/*.TIF
!**/*.TIFF
!**/*.WEBP
!**/*.txt

I prefer the CMD-Shell in Window - or sometimes a CMD-Script:

A:\> set "RESTIC_REPOSITORY=\\Nas\BackUpDrive\BackUpFolder"
A:\> set "RESTIC_PASSWORD=eins,Zwo-Drei!4"
A:\> set "TMPDIR=%tmp%"
A:\> restic backup --iexclude-file OnlySumatraFiles.txt -x --use-fs-snapshot "%UserProFile%"

and I also can backup any other Drive - maybe an eReader:

A:\> restic backup --iexclude-file OnlySumatraFiles.txt "B:\"

Do you see any Errors?

1 Like

what does this file OnlySumatraFiles.txt contain?

*.pdf

???

From Backing up โ€” restic 0.16.3 documentation :

[Negative excludes:] It works similarly to gitignore, with the same limitation: once a directory is excluded, it is not possible to include files inside the directory

That is once a directory has been excluded (due to the /A/* patterns), no files in that directory will be backed up. See also Only include some specific file extensions in backup

1 Like