I have a backup routine that runs for Wordpress sites. There are folders created which are dynamic per installation of Wordpress. I cannot, for the life of me, figure out how to exclude the dynamic folder.
The convention for the dynamic folders are as follows:
/var/www/client1/public_html/wp-content/backupwordpress-aaa1b23456-backups
/var/www/client2/public_html/wp-content/backupwordpress-ccc7d89012-backups
The dynamic portions are backupwordpress-aaa1b23456-backups
and backupwordpress-ccc7d89012-backups
.
I have tired all of the following combinations, and none of them exclude the backupwordpress-*-backups
folder.
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*"
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*/"
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*-backups"
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*-backups/"
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*/*"
tar zcpf client1.tgz /var/www/client1 --exclude="./public_html/wp-content/backupwordpress-*-backups/*"
tar zcpf client1.tgz /var/www/client1 --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*"
tar zcpf client1.tgz /var/www/client1 --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*/*"
tar zcpf client1.tgz /var/www/client1 --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*-backups"
tar zcpf client1.tgz /var/www/client1 --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*-backups/*"
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*" /var/www/client1
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*/" /var/www/client1
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*-backups" /var/www/client1
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*-backups/" /var/www/client1
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*/*" /var/www/client1
tar zcpf client1.tgz --exclude="./public_html/wp-content/backupwordpress-*-backups/*" /var/www/client1
tar zcpf client1.tgz --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*" /var/www/client1
tar zcpf client1.tgz --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*/*" /var/www/client1
tar zcpf client1.tgz --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*-backups" /var/www/client1
tar zcpf client1.tgz --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*-backups/*" /var/www/client1
Here is my version:
tar (GNU tar) 1.29
What am I doing wrong? Thanks!
--exclude="backupwordpress-*-backups"
? If those are the only directories with that sort of name, that ought to match. This would be easier than trying to get the path right. Also, I would put--exclude
before the pathname of the directory you're archiving (although since you're using GNUtar
, I suppose it doesn't matter since GNU utilities tend to reorder the command line arguments, for convenience).tar
version) when I use either--exclude='*/backupwordpress-*-backups'
or a relative path--exclude='var/www/client1/public_html/wp-content/backupwordpress-*-backups'
; I wonder if, when tar strips the leading/
, it stops matching your fully-qualified exclusion pattern?tar zcpf client1.tgz --exclude="/var/www/client1/public_html/wp-content/backupwordpress-*-backups" /var/www/client1
ortar zcpf client1.tgz --exclude="var/www/client1/public_html/wp-content/backupwordpress-*-backups" /var/www/client1
--exclude
. See my comment immediately above.