I'm trying to do a backup in linux I have tried this :
tar --exclude={"logs", "volumes_docker", "Backup"} -zcvf backup1.tar.gz /home/debian
but when I check backup1.tar.gz I find data from yje folders mentioned above.
Could you help please ?
I'm trying to do a backup in linux I have tried this :
tar --exclude={"logs", "volumes_docker", "Backup"} -zcvf backup1.tar.gz /home/debian
but when I check backup1.tar.gz I find data from yje folders mentioned above.
Could you help please ?
Each directory to be excluded should ideally have its own
--excludeflag with the full path specified. E.g.:Ensure that the
--excludepath doesn't contain any symlinked directories (this has bitten me before). When tar encounters a symlinked directory specified by--exclude, it will exclude the symlink itself, not the target directory.Once you have that working, for a more concise approach, you can use brace expansion in the shell (as long as your shell supports it):
Here,
--exclude=/home/debian/{logs,volumes_docker,Backup}is expanded by the shell before the command is executed, effectively making the command equivalent to repeating the--excludeoption for each dir.