Posts Tagged ‘bash’

Bash: Selectively Tar-ing files from a web root (back up your website)

June 15th, 2012 No comments

nice -n 19 find . -type f \( -iname “*.php” -o -iname “*.js” -o -iname “*.inc” \) -print0 | xargs -0 tar rvf dev$(date ‘+%d-%m-%Y’).tar

I had terrible trouble getting this to work the tar wasn’t capturing all the files I eventually found out that I required the print0 and the xargs -0. This would have been trivial with zsh but I didn’t have it this server.

Why the selective backup? because there are huge images and PDFs etc which would have slowed down the backup enormously.

Categories: shell tips Tags: