Score:3

Will this DD command work?

gb flag

I've mounted my Google drive and would like to make a live backup image of my raspberry pi. Would this command work?

sudo dd status=progress if=/dev/mmcblk0 bs=10M conv=sync,noerror | gzip -9 - | dd of=~/mnt/gdrive/RPI/"home server"/backups/$(date +%Y%m%d).gz

I'm not sure if it's an issue copying to a mounted drive, I don't know if it's going to recursively start backing itself up because it's mounted?

catleeball avatar
it flag
I might recommend testing this command with `if=/some/small/file` to see if it works. On the surface it looks like it should. I notice you're using `sudo` with the first dd but not the second dd in the pipeline; be sure you have permissions on the second dd's of= directory, or use sudo if needed.
Score:2
us flag

Yes it will work, mounted storage will not an issue but files which had changed during backup will be corrupted, for test i used boot partition of the test virtual machine with Centos 7

simple script that will make changes to file in second session is:

while :; 
do
  let i++
  echo "test$i" >> /boot/testfile
  sleep 0.5s
done

you can run changing script and then run your command

root@testkvm ~ $  dd status=progress if=/dev/sda1 bs=10M conv=sync,noerror | gzip -9 - | dd of=/tmp/testfile.gz
545259520 bytes (545 MB) copied, 27.401949 s, 19.9 MB/s
51+1 records in
52+0 records out
545259520 bytes (545 MB) copied, 27.4028 s, 19.9 MB/s
206820+1 records in
206820+1 records out
105892004 bytes (106 MB) copied, 27.4112 s, 3.9 MB/s

root@testkvm /tmp $  gunzip /tmp/testfile.gz

root@testkvm /tmp $  mount /tmp/testfile /mnt

root@testkvm /tmp $  cat /mnt/testfile
▒+▒.▒▒▒▒dI▒(i▒-▒)mCa▒▒J!▒إ'[▒▒▒f▒▒;▒)i▒ٳ:g▒▒▒澿▒▒▒▒O▒▒z▒=o▒)�]▒}koy{▒g▒▒s>l▒▒▒▒?U▒lޛ▒▒kλl▒'ۯ▒▒,▒▒▒5▒▒▒o[{▒sw▒▒j▒▒▒)▒▒▒▒▒▒▒▒M|u▒▒▒>׳;▒▒Ҏ▒=▒+?▒▒?N▒▒▒[+▒ol▒▒o▒▒▒ܜ▒?T\▒w▒▒▒▒[▒R▒X▒▒▒n▒▒[▒^▒^▒\▒▒Go▒▒▒▒▒▒ꀻ{ٲ﮺▒▒C7▒\▒▒▒▒O2៮▒w▒mNE▒4▒▒w▒▒▒▒V▒▒
                                                                                                                                                                                                                                         ▒EV>▒▒8▒▒▒▒w▒
▒V▒▒▒▒▒k:▒NO▒▒▒▒V▒pp▒Y▒mg▒μ0▒▒▒▒▒▒L▒▒▒▒▒▒▒▒p▒'▒.▒tÁ▒e▒▒{>▒▒▒▒▒▒▒▒c▒▒{▒{6>:'▒▒▒▒▒{▒▒▒/▒▒>▒▒S▒▒[_▒▒▒▒Zǯ▒W՟:ޝtƿ▒84}▒+▒▒▒▒y▒u▒;▒㍉▒

as you see there is incorrect data

source file at the moment of backup finished looks like:

root@testkvm  ~ $  cat /boot/testfile
test1
test2
test3
...
test72

so you can backup with this command only if you're sure there will no any changes during backup

gb flag
Very good point, it's been running for about 29000 seconds now and since the drive is mounted via Rclone I'm worried that the ever enlarging .cache folder is being backed up onto itself.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.