Tuesday, March 2, 2021

how to backup project folder in server -Download/upload files to server

1) usw pwd to get the correct directory (eg. /app/odset )

2)then cd /tmp and archive using any of the below commands

    tar -czvf bckup_filename.tar.gz  /app/odset

                or

    zip -r bckup_filename.tar.gz /app/odset


3) the compressed folders will be present there

4) download it to your system using filezilla(right click->download) or 

by typing  scp command in your terminal

        scp -P 87 username@hostname:/tmp/backupfilename.gz  . 

//to upload it to server

scp sourceUsername@hostname:/home/path/to/localFile/filename.dbbckup.sql.gz  destinationUsername@hostname:/tmp

//no need to mention username@hostname for our own local computer as source

Eg:

scp /home/sabeeha/alphaServer/27May2021Alpha.dbbckup.sql.gz  o3cgj3skbznio-integration-5ojmyuq--mymagento@ssh.ap-3.magento.cloud:/tmp

sudo scp -r -i ~/.ssh/Mysecret.pem filename.tar ubuntu@ec-x-xxx-xxx-xx.compute-1.amazonaws.com:/home/ubuntu

//'.' stands for current folder

//'~' stands for working directory path


5)unzip using unzip command (for .zip folder) or gunzip command for (.gz) files

unzip filename.zip .

gunzip filename.tar.gz       // result will be filename.tar

tar -xf archive.tar    //result will be filename
 
---------------------------------------------------------------------------------------
To copy files without intermediate save,
 
1)Frmo server to host (download directory)
host$  ssh user@host "tar -C /path/to/data/ -zc directory_name" | tar zx 
2)from host to server(upload directory)
tar zc directory_name/ | ssh user@host "tar zx -C /new/path/to/data/" 

No comments:

Post a Comment