Page 4 of 5
Re: SD card backup / copy: how to ?
Posted: Sun Jan 03, 2016 9:31 am
by davenull
the problem is:
the Raspi has a tiny screen, I can't recognize almost nothing of the miles of commandline parameters which are or have to be written and it's a torture to use Iceweasel on this screen.
So I always have to copy 1 line from my PC to the thread, change to the Raspi, start Iceweasel, try to find this forum, try to find the topic, try to find the post, then try to find this line by Iceweasel anyhow again, try to c+p it into the LX terminal, and having done that I don't see anything what's actually happening, just if there once will appear a new prompt or not.
All that entire whole minus this and minus that and minus theother and minus onemore and minus againonemore is incredibly confusing me!
It was much easier if I had a program or just a script to start which is configured correctly and which I can start from cmd line by sth like
./backup
(or just by double-click on it's desktop link)
These 8 characters I can handle, but nothing more additionally.
So can you please give me a correctly written command line which backups everything to my usb drive ( /media/pi/USB120DRV/ )
- the whole root dir
- and the whole pi dir ?
and which I only need to c+p just the way it's written?
(unfortunately I found out that many important folders have been automatically stored at /pi/ and not at / as I had expected before)
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 2:31 pm
by davenull
I'm still clueless, what is faulty with this?
Code: Select all
sudo tar --exclude=/media/* --exclude=/proc --exclude=/dev --exclude=/tmp --exclude=/run cvzf /media/pi/USB120DRV/pibackup.tar.gz /
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 2:57 pm
by jojopi
Exactly the same thing. "cvzf" just looks like a file name. You need "-cvzf".
Historical versions of tar did not have options, but expected a clump of letters as the first argument. This is still supported for compatibility, but only when it is the very first argument.
The modern way to write options, for all programs, is with a leading hyphen.
(Usually you can clump single-letter options together if they do not take arguments. Therefore options that are full words like --exclude require two hyphens.)
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 3:06 pm
by davenull
ah, ok, thank you - I have to apologize, I don't always understand everything at once because I'm not good in English.
Code: Select all
sudo tar --exclude=/media/* --exclude=/proc --exclude=/dev --exclude=/tmp --exclude=/run -cvzf /media/pi/USB120DRV/pibackup.tar.gz /
and the blank space at the end is correct between
../pibackup.tar.gz
and
/

Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 4:10 pm
by jojopi
davenull wrote:and the blank space at the end is correct between
../pibackup.tar.gz and /

Yes, …/pibackup.tar.gz is the name of the archive you are creating. It is the argument to the "-f" part of the preceding "-cvzf" option. Everything that is not an option or an argument to an option, is a file or directory to back up. So "/" means to backup everything, except the directories you already excluded.
Incidentally, you should add "--exclude=/sys" as well. It is a virtual filesystem, similar to /proc, and does not store real data. An alternative to lots of exclusions is to tell tar to stay in the filesystem you specify, and then name the two filesystems you care about: / and /boot:
Code: Select all
sudo tar -cvzf /media/pi/USB120DRV/pibackup.tar.gz --one-file-system / /boot
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 4:12 pm
by davenull
thank you very much!
Code: Select all
sudo tar --exclude=/media/* --exclude=/proc --exclude=/sys --exclude=/dev --exclude=/tmp --exclude=/run -cvzf /media/pi/USB120DRV/pibackup.tar.gz /
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 6:15 pm
by grumpy_dad
I doubt rsync can restore in case of an SD card corruption, in which case you'll need to wipe everything and reinstall. I simply make SD card clones every month and save 3 most recent clones, it's much easier to restore as well (at least for me!). I just have an 8gb sd card.
Re: SD card backup / copy: how to ?
Posted: Tue Jan 05, 2016 6:57 pm
by davenull
quite that had been almost my next question:
In case files and folders of the the SD card got damaged, deleted, or corrupted:
by which command can I restore everything from the pibackup.tar.gz file?
At the worst case:
if I had to make a complete new installation by NOOBS (the first basic installation),
and now want to update to my latest backup state?
( I now have the pibackup.tar.gz file (1.5 GB) in the root dir of my USB drive ( USB120DRV ).
Re: SD card backup / copy: how to ?
Posted: Wed Jan 06, 2016 3:07 am
by stderr
grumpy_dad wrote:I doubt rsync can restore in case of an SD card corruption, in which case you'll need to wipe everything and reinstall. I simply make SD card clones every month and save 3 most recent clones, it's much easier to restore as well (at least for me!). I just have an 8gb sd card.
This was why having an image of the boot and os while keeping the data on a different drive/partition makes sense.
Re: SD card backup / copy: how to ?
Posted: Wed Jan 06, 2016 8:24 am
by davenull
asandfort (edited) wrote:If you really want a one liner:
Code: Select all
sudo tar --exclude=/media/* --exclude=/proc --exclude=/dev --exclude=/tmp --exclude=/run -cvzf /media/pi/USB120DRV/pibackup.tar.gz /
so how to proceed then in case of need to restore the files from the *.tar.gz ?
davenull wrote:
In case files and folders of the the SD card got damaged, deleted, or corrupted:
by which command can I restore everything from the pibackup.tar.gz file?
At the worst case:
if I had to make a complete new installation by NOOBS (the first basic installation),
and now want to update to my latest backup state?
( I now have the pibackup.tar.gz file (1.5 GB) in the root dir of my USB drive ( USB120DRV ).
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 2:32 am
by asandford
davenull wrote:
so how to proceed then in case of need to restore the files from the *.tar.gz ?
google "extract a gzipped tarball"
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 8:28 am
by davenull
Code: Select all
unzip -xvzf /media/pi/USB120DRV/Akten/ pibackup.tar.gz /
??
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 10:40 am
by DougieLawson
cd /tmp # change to the directory when you want the output stored
tar xavf /media/pi/USB120DRV/Akten/pibackup.tar.gz # NO SPACES between directories and filenames
That xavf stuff means x == extract, a == analyse, v == verify, f == filename. The analyse parameter gets the tar program to read the magic numbers from the file (defined with the filename parameter) and choose the right way to unzip it before "untar'ing" it.
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 11:05 am
by davenull
thank you!
what means
cd /tmp # ?
what is /tmp?
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 11:37 am
by DougieLawson
/tmp is the temporary directory, it's a place to put things that you don't want to keep beyond the next time the system gets booted.
I just used it as an example because, by convention, you should NOT write stuff to the root (/) directory. You could use your home directory cd ~.
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 11:52 am
by davenull
well, my situation is as follows:
I have a backup tar file on my USB drv
and - in case my raspi root dir ane maybe others have become corrupted - I now want to overwrite all existing files and folders on my Raspi and addtionally all those which have (or might have) been deleted.
So the uncompress (unzip) function now should restore everything to the state of the last backup.
IMO it also must copy all and everything on root and home and pi and all that automatically, too.
So I open the LX Terminal (even better: the File Manager),
move to the USB folder,
and start the restore program out of that folder.
Code: Select all
tar xavf /media/pi/USB120DRV/Akten/pibackup.tar.gz
Is this the functionality which is provided and which is needed?
Does this tar command know then to which path and to which folders it has to write all and everything?
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 12:58 pm
by DougieLawson
Try typing this
man man
then this
man tar
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:32 pm
by davenull
the man is too cryptic and too technical English, too hard to understand for my poor English skills.
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:35 pm
by rpdom
davenull wrote:the man is too cryptic and too technical English, too hard to understand for my poor English skills.
Try this then
http://manpages.debian.org/cgi-bin/man. ... &locale=de
You could also try installing the manpages-de package which should give you local man pages for many commands in German.

Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:37 pm
by davenull
ok, lets se...
Mod edit: Just imagine the whole man page for tar in German, right here.I know you don't really want to see it.
author's edit:
no, I want to see it, because I have to see all the options which are actually possible, in order to access it at any time and not to risk to miss anything.
As it is not forbidden to post a documentation acc to forum's rules, I would insist to keep them visible.
[mod edit. Please stop posting the man page as it adds nothing to the forum and just clutters up the thread with extra verbage that is not required, also this is not the German language forum. if you want to keep it handy print it out and file it in a ring binder.]
[german tar manpage delted by mod]
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:45 pm
by davenull
THAT stuff is REALLY weird!!
xavf
1st I see: shouldn't it be -xavf == -x -a -v -f ?
x is ok
-x, --extract, --get
Dateien aus einem Archiv extrahieren
a is strange: why that ?
-a, --auto-compress
Die Archiv-Endung verwenden, um das Kompressionsprogramm herauszu-
finden
v verbose....well....list everything... not needed!
f don't find!
but my question is still not answered:
So I open the LX Terminal (even better: the File Manager),
move to the USB folder,
and start the restore program out of that folder.
Code: Select all
tar xavf /media/pi/USB120DRV/Akten/pibackup.tar.gz
Is this the functionality which is provided and which is needed?
Does this tar command know then to which path and to which folders it has to write all and everything?
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:48 pm
by DougieLawson
The minus sign on my keyboard sticks so I don't like to wear it out.
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:49 pm
by davenull
haha, that is funny, ok then
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 1:50 pm
by davenull
so for restoring = EXTRACTING this file
/media/pi/USB120DRV/Akten/pibackup.tar.gz
is this the correct procedure?
So I open the LX Terminal (even better: the File Manager),
move to the USB folder,
and start the
restore program out of that folder by this command:
Code: Select all
tar -xavf /media/pi/USB120DRV/Akten/pibackup.tar.gz
Is this the functionality which is provided and which is needed?
Does this tar command know then to which path and to which folders it has to write all and everything during EXTRACTING ?
I want to extract to restore, not to compress!
Re: SD card backup / copy: how to ?
Posted: Thu Jan 07, 2016 2:00 pm
by davenull
in the German man page they only say
Alle Dateien aus archive.tar extrahieren.
tar -xf archive.tar
to restore though.
that would mean by my settings:
Code: Select all
tar -xf /media/pi/USB120DRV/Akten/pibackup.tar.gz
no -v parameter, no -a parameter.
correct?