B
B
brar2018-11-28 14:41:02
linux
brar, 2018-11-28 14:41:02

How to archive to the network with the creation of the necessary directory?

Hello.
The following command creates an archive by adding a date to the name.

tar -czvpf - /bla/bla/ | ssh [email protected] cat > /backups/bla_$(date +%Hh_%Mm_%d_%B_%Y).tar.gz

Please tell me how to change the command so that a directory is created with the name and date in its name at the end.
tar -czvpf - /bla/bla | ssh [email protected] cat > /backups/bla_$(date +%Hh_%Mm_%d_%B_%Y)/bla.tar.gz

Naturally, it does not work, since cat did not find the option to create a directory in the mana if it is missing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2018-11-28
@brar

What's stopping you from running the command?

DATE=$(date +%Hh_%Mm_%d_%B_%Y)
mkdir -p /backups/bla_${DATE}/

before doing
?
Well, or if you really need it - in one line
DATE=$(date +%Hh_%Mm_%d_%B_%Y);mkdir -p /backups/bla_${DATE}/;tar -czvpf - /bla/bla | ssh [email protected] cat > /backups/bla_${DATE}/bla.tar.gz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question