LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-16-2018, 09:51 PM   #1
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
dd command not working


Hello everyone,

So I'm trying to make a backup of my windows drive using dd but the following command doesn't seem to work all I get is a '>':

Code:
backups # dd if=/dev/nvme0n1 conv=sync,noerror status=progress bs=64K | gzip -c > /backups/windows/windows-"`date +"%Y%m%d_%H%M"`.img.gz
>
But if I do the same without the date it works:

Code:
dd if=/dev/nvme0n1 conv=sync,noerror status=progress bs=64K | gzip -c > /backups/windows/windows.img.gz
What am I doing wrong with the date as I would like the date in the filename.

Anyone got any ideas why this isn't working?

Thanks for your help with this.
 
Old 11-16-2018, 09:57 PM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by lazydog View Post
Hello everyone,

So I'm trying to make a backup of my windows drive using dd but the following command doesn't seem to work all I get is a '>':

Code:
backups # dd if=/dev/nvme0n1 conv=sync,noerror status=progress bs=64K | gzip -c > /backups/windows/windows-"`date +"%Y%m%d_%H%M"`.img.gz
>
But if I do the same without the date it works:
The date command contains too many " chars, try removing the one before the first back-quote.

Last edited by ehartman; 11-16-2018 at 09:58 PM. Reason: missing quote terminator
 
Old 11-16-2018, 10:45 PM   #3
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Bingo! Thnx. Just over looked that. Guess doing this when you are tired isn't a good idea.
 
Old 11-16-2018, 11:59 PM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by lazydog View Post
Bingo! Thnx. Just over looked that. Guess doing this when you are tired isn't a good idea.
BTW: you can simplify the date command by using %F
Code:
date "+%F_%H%M"
which is better looking or even eliminate the time altogether as you normally don't make more then one backup per day. Then you can eliminate the double quotes altogether
Code:
date +\%F
 
Old 11-17-2018, 11:30 PM   #5
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
ehartman, Thnx for this information. The %F inserts dashes in the date which is what I'm trying to stay away from.
 
Old 11-18-2018, 03:52 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
just a comment (or two): it was not the dd, so your title is misleading (you stated in your first post, without date it worked).
in similar cases I would suggest to generate the filename first, put/store it into a variable and use that:
Code:
MY_FILE=$(date +"windows-%Y%m%d_%H%M.img.gz")
dd ... | gzip ... > "/this/dir/${MY_FILE}"     # << use " here
This make it more readable, (you can use set -xv to check how does it really works) and yes, more stable - as you can see.
And finally if your problem is solved, please mark the thread solved. Also if you wish to say thanks to someone just click on yes.
 
Old 11-19-2018, 10:36 AM   #7
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249

Original Poster
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
One of the things I like about linux, there is more than one way to get the job done.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ILO: Using Virtual Media with the Command-Line Interface command not working on ILO3 LittleMaster Linux - Server 0 10-31-2017 11:44 AM
[SOLVED] Command working on command line but not in shell script markplus Linux - Newbie 28 12-03-2016 08:01 AM
Synaptic package not working from xcfe yet working from the command line onerous Debian 8 11-15-2012 03:40 PM
[SOLVED] command line cd command not working right bjrn64 Linux - Software 6 05-10-2010 05:46 AM
mount command not working in chroot. and now chroot not working mohit.jain Linux From Scratch 5 07-14-2006 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration