DEV Community

Arshan Nawaz
Arshan Nawaz

Posted on

Download your Mern stack app Using scp (Secure Copy)

Step 1: Create Backup on Server
Connect to Your Server:
Use SSH to connect to your server. Replace and with your server's username and IP address.

ssh <remote-user>@<remote-ip>
Enter fullscreen mode Exit fullscreen mode

Step 2: Create a Backup Directory (if not already created):
Create a directory to store your backups. For example, let's create a directory named backups in your home directory.

mkdir -p ~/backups
Enter fullscreen mode Exit fullscreen mode

Step 3: Create the Backup:
Assuming your application files are in /var/www/websiteFolder/, create a backup of the portfolio directory.

tar -czvf ~/backups/app-backup-$(date +%F).tar.gz /var/www/portfolio/
Enter fullscreen mode Exit fullscreen mode

Step 4: Download Backup to Local Machine
Open a New Terminal Window (on your local machine):
Open a new terminal window or tab on your local machine.

Download the Backup:
Use the scp command to download the backup file from the server to your local machine. Replace , , and accordingly.

scp <remote-user>@<remote-ip>:~/backups/app-backup-$(date +%F).tar.gz <local-path>
Enter fullscreen mode Exit fullscreen mode

for Mac

mkdir -p /Users/username/backup
scp <remote-user>@<remote-ip>:~/backups/app-backup-$(date +%F).tar.gz /Users/username/backup
 app-backup-$(date +%F).tar.gz is file name. Also you can verify the name.
Enter fullscreen mode Exit fullscreen mode

Step 5: Extract Backup file
Open terminal in /Users/username/backup and run command

tar -xzvf app-backup-2024-05-21.tar.g
 app-backup-2024-05-21.tar.g is file name, it can different in your case
Enter fullscreen mode Exit fullscreen mode

Top comments (0)