A shell tool for uploading directory as a tar file to server.
USER_SERVER="root@yourserver"
UPLOAD_DIRECTORY="/local/path/to/the/folder"
SERVER_DIRECTORY="/backup/path/on/the/server"
such as
USER_SERVER="[email protected]"
UPLOAD_DIRECTORY="/usr/uploaddir"
SERVER_DIRECTORY="/root/backup"
chmod +x ./upload-tar.sh
- Make sure you have your own public key.
- Get your local public key by
more ~/.ssh/id_rsa.pub
. - Add it to the tail of the file
~/.ssh/authorized_keys
on your server.
./upload-tar.sh
It will tar the UPLOAD_DIRECTORY as a tar.gz file and upload to the server.
./upload-tar.sh clean
Clean the directory on the server. It will remove the packages uploaded before the current date.
./upload-tar.sh cleanall
Clean the directory on the server. It will remove all the packages for safety.