I suggest you to use
rsync instead of backuping your files manually. With this tool, you can do exactly what you're doing with some extra features. For example, you can pass the
--progress argument to know the last file copied.
Another feature is that you can copy only the new files or the modified ones, which will reduce the amount of data transmitted through the network. If you set the
--delete argument, it will delete the files that you removed in your source folder. Finally,
-z argument enables compression.
The command has the following structure:
$ rsync options source destination
rsync --progress -azv -e ssh --delete /home/guandalino/ \
--progress displays detailed progress of rsync execution
-z enables compression
-v means verbose
-a indicates recursive. Also, it preserves permissions, owner, group etc.
--delete deletes files that are not there in source directory.
Take a look at this examples.
This part is extra. This is how I use it to backup my home folder to my server automatically. I put the above example in a shell script file and enabled
cron to run it every day, at 00:00AM.
00 00 * * * /home/guandalino/backup_home_folder.sh 2>&1 >> /var/log/backup_home_folder.log
I redirect the output of script to a file in order to keep a log of the transmission. You'll have to generate a public key with
ssh-keygen -t rsa if you don't have one yet, so your client will be allowed to connect to the server without entering your password.