Discussion:
Bug?
(too old to reply)
Richard Bostrom
2024-07-14 08:20:02 UTC
Permalink
Executing this script halts it after the tar with the following message.

--
#!/bin/sh
tar -zcvf bak.tar.gz /home/user/Documents &&
gpg -r ***@user.local -e bak.tar.gz &&
rm -rf bak.tar.gz &&
rsync -vac --delete /home/user/Documents/bak.tar.gz.gpg /media/user/6548-2136 &&rm -rf bak.tar.gz.gpg

tar: file changed as we read it.
--

I've split the script into two parts.

script 1
--
tar -zcvf bak.tar.gz /home/user/Documents &&

&

script 2
--
gpg -r ***@user.local -e bak.tar.gz &&
rm -rf bak.tar.gz &&rsync -vac --delete /home/user/Documents/bak.tar.gz.gpg /media/user/6548-2136 &&rm -rf bak.tar.gz.gpg

--

Everything works. When setting the scripts up as cronjobs with script 2 several minutes behind each script 1. The backup file ends up stuck in my home directory .

LinuX
Nicolas George
2024-07-14 09:00:01 UTC
Permalink
Post by Richard Bostrom
tar -zcvf bak.tar.gz /home/user/Documents &&
Information missing: what is the current directory.
Post by Richard Bostrom
rm -rf bak.tar.gz &&
rsync -vac --delete /home/user/Documents/bak.tar.gz.gpg /media/user/6548-2136 &&rm -rf bak.tar.gz.gpg
Fortunately, we have the information: the current directory is
/home/user/Documents.
Post by Richard Bostrom
tar: file changed as we read it.
The message says it exactly as it is.

Solution: do not use the directory you are trying to backup as a
directory for temporary files at the same time.

Regards,
--
Nicolas George
David Christensen
2024-07-14 09:10:02 UTC
Permalink
Post by Richard Bostrom
Executing this script halts it after the tar with the following message.
--
#!/bin/sh
tar -zcvf bak.tar.gz /home/user/Documents &&
rm -rf bak.tar.gz &&
rsync -vac --delete /home/user/Documents/bak.tar.gz.gpg /media/user/6548-2136 &&rm -rf bak.tar.gz.gpg
tar: file changed as we read it.
--
Assuming your script is named /home/user/script and your current working
directory is /home/user, please run the following commands in a terminal
and post the complete console session -- prompts, commands entered,
output displayed:

$ cat /etc/debian_version; uname -a

$ cd

$ pwd

$ ls -l bak.tar.gz*

$ ls -l /media/user/6548-2136

$ cat script

$ sh -x script

$ ls -l bak.tar.gz*

$ ls -l /media/user/6548-2136


David

Loading...