tar: /: file changed as we read it tar: Exiting with failure status due to previous errors

12,541

Your tar -cvpzf backup.tar.gz ... command puts backup.tar.gz in the current directory (which is the home directory of root, /root, in the default installation). You exclude --exclude=/backup.tar.gz, which, in this case is not the same as $PWD/backup.tar.gz.

cd / and try again, or be consistent with the filename.

Share:
12,541

Related videos on Youtube

MiniBug
Author by

MiniBug

Updated on September 18, 2022

Comments

  • MiniBug
    MiniBug over 1 year

    There are a bunch of duplicates of this question but none of them works for me.

    I'm trying to make a back up of my ubuntu 16.04. web server on AWS.

    Executing commands like so:

    sudo su -
    
    tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys --exclude=/run --exclude=/media --exclude=/var/cache/apt/archives /
    

    the latest output I get is this:

    /lib/systemd/systemd-hostnamed
    /lib/systemd/systemd
    /lib/systemd/systemd-activate
    /opt/
    /vmlinuz.old
    /initrd.img.old
    tar: /: file changed as we read it
    tar: Exiting with failure status due to previous errors`
    

    How should I make a full backup?

    I successfully made a backup of my locally installed Red Hat 4.8.3-9

    • mdiehl13
      mdiehl13 about 5 years
      Hi, check out option #2 in this solution from Mohammad Azim. stackoverflow.com/a/37993307/277601. He 'touch'd the backup.tar.gz before the tar command so that the --exclude=backup.tar.gz would work since the file existed.