Created
January 13, 2024 13:08
-
-
Save eurowebpage/fc955ed898ba49a74444163a6acf3962 to your computer and use it in GitHub Desktop.
Save Backup files on remote server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
###################################### | |
# sshpass - ssh. | |
# Backup script. | |
# Save on remote server. | |
###################################### | |
# Local directories to backup | |
backup_files="/media/ /test/" | |
# Where to backup to. Remote server | |
dest="~/img" | |
# Create archive filename. | |
day=$(date +%A) | |
hostname=$(hostname -s) | |
# Print start status message. | |
echo "Backing up $backup_files to $dest/" | |
date | |
echo | |
# Backup the files using tar. | |
tar cvjf - $backup_files | sshpass -p eurowebpage ssh eurowebpage@terra "(cd $dest; tar xjf -)" | |
# Print end status message. | |
echo | |
echo "Backup finished" | |
date | |
# Long listing of files in $dest to check file sizes. | |
sshpass -p eurowebpage ssh eurowebpage@terra "ls -lh $dest" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment