#!/bin/sh ########################################################################### # # Copyright (c) 2022-2023 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file export_logs.sh # # @author (last) Behrouz NematiPour # @date (last) 14-Jan-2022 # @author (original) Behrouz NematiPour # @date (original) 14-Jan-2022 # ############################################################################ CURRNET_DATE=$(date +%Y_%m_%d) PATH_SRC="$1" PATH_DST="$2" PASS_HAS="$3" function echo_usage() { if [[ -z "$PATH_SRC" || -z "$PATH_DST" ]]; then echo "Usage:" echo "./export_logs.sh " echo "" fi } function export_logs() { OPTP="" PASS="Empty Password" if [[ -n "$PASS_HAS" ]]; then PASS=$(pwgen -ABcsnv1 16) OPTP=--password="$PASS" fi EXPORT_FILE=$CURRNET_DATE"_logs" echo "$PATH_DST"/"$EXPORT_FILE".zip # echo the out zip rm -frd "$PATH_DST"/"$EXPORT_FILE".zip && # remove the old zip from dest rm -frd $HOME/"$EXPORT_FILE".zip && # remove the old zip from home zip -jr9 $HOME/"$EXPORT_FILE".zip "$PATH_SRC" "$OPTP" && # compress the new zip to home neesd to change to 7zzs cp $HOME/"$EXPORT_FILE".zip "$PATH_DST" && # copy the new zip to dest echo $PASS > "$PATH_DST"/"$EXPORT_FILE".pas && # copy the new pas to dest rm -frd $HOME/"$EXPORT_FILE".zip # remove the tmp zip from home } if [[ "$1" == "" ]]; then echo_usage fi export_logs