Jump to content
php.lv forumi

Saspiest mongo datubāzes dumpu un nosūtīt uz ftp ar .sh


Recommended Posts

Posted
#!/bin/bash
NOW=$(date +"%m-%d-%Y")
echo $NOW

#creat db backup
mongodump -u ****** -p ****** -o /home/mongod/mongobackup/mongodBackup-$NOW --gzip
tar -cvzf mongodBackup-$NOW.tar.gz /home/mongod/mongobackup/mongodBackup-$NOW

HOST='******'
USER='******'
PASSWD='******'
FILE='mongodBackup-'$NOW'.tar.gz'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /mongodbbackup
put $FILE
quit
END_SCRIPT
exit 0

Mēģinu saspiest mongodumpu un ielādēt uz serveri, bet atverot rāda ka arhīvs ir saplēsts. Kas varētu būt pa vainu?

 

Ubuntu

Posted

ftp pie vainas,

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
cd /mongodbbackup
put $FILE
quit
END_SCRIPT
exit 0

Pieliku binary, un viss aizgāja. Paldies :)

Posted (edited)

Es pareizi saprotu, ka tu vispirms viņu ar mongo dump tūli saspied ar parametru --gzip, un pēc tam tar tūlim pieliec -z parametru otreizējai zipošanai?

Edited by Mr.Key
Posted

Jā, ideja tāda bija, jo mongodump uztaisi kaudzi ar failiem un mapītēm, gribās vienu. Beigu variantā noņemu --gzip, jo saspiežu pa taisno mapītes un failus. Nav jēga divreiz saspiest.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...