linux - backup script in shell -


i new in shell script.will please suggest how write backup shell script. having following formated data in target directory.

storeid_date_time.zip

like:

-rw------- 1 rupesh ldapusers  8267310 mar 22 12:00 44_22032014_115629.zip  -rw------- 1 rupesh ldapusers  8269938 mar 22 12:07 44_22032014_120013.zip  -rw------- 1 rupesh ldapusers  8267110 mar 22 12:14 44_22032014_120704.zip  -rw------- 1 rupesh ldapusers  8254223 mar 22 14:25 45_22032014_142155.zip  -rw------- 1 rupesh ldapusers  7871060 mar 22 12:11 48_22032014_120813.zip  -rw------- 1 rupesh ldapusers  8314418 mar 22 12:22 48_22032014_121038.zip  -rw------- 1 rupesh ldapusers  8254699 mar 24 12:13 49_22032014_145338.zip 

now want backup files following way:

backup directory : /backup/date/storeid/zip files of store

like:

/backup/22032014/44/44_22032014_115629.zip,44_22032014_120013.zip...so on  /backup/22032014/45/45_22032014_142155.zip  /backup/22032014/48/48_22032014_120813.zip,48_22032014_121038.zip  /backup/22032014/49/49_22032014_145338.zip 

for next day /backup/23032014/respective_storeidfolder&files

please give hint or code example can move foreword.

i have coded in bare minimum steps without doing real check verified it. works fine dummy files created on box :)

#!/bin/bash   in $(find * -type f -iname '*.zip' )      echo "zip file :  "$i      store_id=$(echo $i | cut -d "_" -f 1  );      timestamp=$(echo $i | cut -d "_" -f 2  );      echo store id = ${store_id}      # assuming these directories here of teh same pattern name. else put numeric check down.      mkdir -p /backup/${timestamp}/${store_id}      cp -f $i /backup/${timestamp}/${store_id}/ done; 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -