3

I am trying to find a way to create and update a tar archive of files on a remote system where we don't have write permissions (the remote file system is read only) over ssh. I've figured out that the way to create a archive is,

ssh user@remoteServer "tar cvpjf - /" > backup.tgz

However, I would like to know if there is some way of performing only incremental backups from this point on (of only files that have actually changed?). Any help with this is much appreciated.

Bootstrapper
  • 1,089
  • 3
  • 14
  • 33
  • Maybe you can mount the remote file system in your local machine, where you have write permissions, through `sshfs` – salva Oct 11 '13 at 06:28

1 Answers1

2

You can try using the --listed-incremental option of tar:

http://www.gnu.org/software/tar/manual/html_node/Incremental-Dumps.html

The main problem is that you have no option to pipe the snar file through the stdout because you are already piping backup.tgz so the best option to store it would be to create the file in the /tmp directory where you should have write permissions and then download it at the end of the backup session.

For example:

ssh user@remoteServer "tar --listed-incremental=/tmp/backup-1.snar -cvpjf - /" > backup-1.tgz
scp user@remoteServer:/tmp/backup-1.snar

And in the following session you will use that .snar file to avoid copying the same files:

scp backup-1.snar user@remoteServer:/tmp/backup-1.snar
ssh user@remoteServer "tar --listed-incremental=/tmp/backup-1.snar -cvpjf - /" > backup-2.tgz
alcachi
  • 598
  • 6
  • 12
  • Thanks, this works great. I am trying to put this in a script however keep getting prompted for the password twice (ssh and scp). Is there anyway to get these 2 done together? – Bootstrapper Oct 11 '13 at 18:35
  • 1
    You can use pasword-less authentication using ssh keys: http://www.debian-administration.org/articles/152 – alcachi Oct 16 '13 at 10:07