1

Currently I'm working on my bash script which does backup mysql data, the only problem I got is the parameter of tar which was working on the debian, but its not working on FreeBSD.

Yes, I have read this: Deleting files after adding to tar archive

And the answer is the solution I was always using on debian - I mean the --remove-files parameter.

Executing the following command on FreeBSD:

tar --remove-files -jcPf $DIR/$Y/$M/$D/mysql-$HOUR.tar.bz2 *.sql

Throws the following error:

tar: Option --remove-files is not supported

I havent found anything similar to the --remove-files param. while reading the man tar, so what is the solution?

Community
  • 1
  • 1
Scott
  • 5,991
  • 15
  • 35
  • 42

1 Answers1

0

Does it have to be tar option? Most probably --remove-files is gnu extension (or whatever), so you'd probably be able to just install this 'extended' version of tar on FreeBSD and use it.

If you cannot/don't want to, I think this would do:

tar -jvcPf $DIR/$Y/$M/$D/mysql-$HOUR.tar.bz2 *.sql | xargs rm

BTW, I think the '-' can (and should) be omitted from the tar options...

ishi
  • 729
  • 7
  • 10