Skip to content
Advertisement

when adding files to tar the tar overwrites itself halfway through the command [closed]

I have a command that I have been using for some time. Since I moved from windows to ubuntu I noticed a problem when using SSH and issuing the following command:

find /var/lib/psa/dumps/ -type f -name “1510310222” -exec tar cvf 1510310222_31102015.tar {} +

Normally this command runs on my plesk server and collects all the files in the dumps folder with the name of the last backup. 1510310222 in this case.

As the command executes, files get added to the tar as expected and it gets up to 80GB.

Near to the end it shows a warning: tar: Removing leading `/’ from member names

After the warning, the rest of the remaining files then overwrite the tar. Leaving it at 80MB

When opening the tar it only has files from after the warning.

Advertisement

Answer

find‘s -exec predicate may run the command multiple times if the arguments are too long for a single command line. Create an empty archive first and use tar to append to that archive instead of creating it.

Advertisement