script to move files and zipi

Forum rules
Before you post please read this

script to move files and zipi

Postby specimen on Fri Mar 28, 2014 8:40 pm

I am not sure whether or not this subject is posted in the right forum.

I need to copy the entire contents of a partition on a networked windows machine (ex: \\10.1.42.xx\d:) and p7zip it into "\home\jeff\dump" folder on my mint box. The compressed file should be maximum deflated, save full path info of the source files and folders and have a date stamp in the filename (ex: backupfile28032014.7z )

Is this easily done and if so, would anyone post a script exaple? Thanks!
specimen
Level 1
Level 1
 
Posts: 11
Joined: Fri Mar 28, 2014 8:09 pm

Linux Mint is funded by ads and donations.
 

Re: script to move files and zipi

Postby Pilosopong Tasyo on Fri Mar 28, 2014 10:07 pm

specimen wrote:I am not sure whether or not this subject is posted in the right forum.

Move from Newbie Questions to Scripts & Bash. FIFY. ;)
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1180
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: script to move files and zipi

Postby specimen on Fri Mar 28, 2014 10:20 pm

Thanks very much for doing this. Much appreciated!
specimen
Level 1
Level 1
 
Posts: 11
Joined: Fri Mar 28, 2014 8:09 pm

Re: script to move files and zipi

Postby xenopeek on Sat Mar 29, 2014 6:28 am

That would just be one command I think. Have a look at the 7zr manpage:
Code: Select all
man 7zr
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14995
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: script to move files and zip

Postby specimen on Sun Mar 30, 2014 11:25 am

Thanks very much. The actual compression bussiness is handled in one line:
(ex: sudo 7zr -t7z a //10.1.42.76/dump/backupfile.7z //source/ddrive mx5).

What im having trouble with is developing a bash script that deploys on a shedule and stamps the date into the zip file name to make it unique. Id like the file name to be something like this: backupfile30032014.7z indicating the date the script was deployed.

I know how to do this in a windows batch. I just want to get away from ms and need a helping hand.

Thanks for your time in replying!
specimen
Level 1
Level 1
 
Posts: 11
Joined: Fri Mar 28, 2014 8:09 pm

Re: script to move files and zipi

Postby xenopeek on Sun Mar 30, 2014 3:46 pm

Replace "backupfile.7z" in your command with the following (this is for bash):
Code: Select all
backupfile$(date +%d%m%Y).7z

Personally, I prefer using YYYYMMDD format over DDMMYYY, as that sorts better on name :wink: That would be:
Code: Select all
backupfile$(date +%Y%m%d).7z
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14995
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: script to move files and zipi

Postby specimen on Sun Mar 30, 2014 4:54 pm

Outstanding. Thank you so much for the example. Now that I think of it, I like your date suggestion better.
specimen
Level 1
Level 1
 
Posts: 11
Joined: Fri Mar 28, 2014 8:09 pm

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 3 guests