Aug 10, '05 09:51:00AM • Contributed by: ruaric
Note that the machine you are backing up to must be running an FTP server and have enough free space. OS X and most Linux distributions include an FTP server (it may need to be enabled), and there are a number of free ftp servers available for Windows.
To back up your home directory, you would issue the following commands from a command prompt:
$ cd ~
$ cd ..
$ ftp ftp_server_name
You will then be prompted for the username and password required to connect to the FTP server. Once you have logged in, change to the relevant FTP directory using the cd command, and then at the FTP prompt, issue the following commands:
ftp> bin
ftp> put "| tar cvpf - username" username_backup.tar
Replace username with your actual username!
This will place your user directory into a tar file called username_backup.tar, which will be uploaded onto the FTP server. If the machine you are connecting from is running Tiger, then your permissions and resource forks will be preserved within the tar file, hence it does not matter what operating system the FTP server is running.
If you are running an older version of Mac OS X, then you should download and install Xtar and use this in place of the tar program that's included with OS X. This is because the standard tar program included with older versions of OS X did not support resource forks. So you would change the above ftp put command to:
ftp> put "| xtar cvpf - username" username_backup.tar
To restore your backup, you would issue the following commands from the FTP prompt:
ftp> bin
ftp> get username_backup.tar "| tar xvpf -"
Or if you were using older versions of OS X and had Xtar installed:
ftp> get username_backup.tar "| xtar xvpf -"
A couple of important notes. Firstly, the version of tar you used to backup must also be used for the restore. This is because the way resource forks are stored within the tar file is not fully compatible between Tiger's tar and Xtar. Secondly, you could also use this technique to back up the whole Users directory, and/or the Applications and Library directories as well. If you do this, you will need run the tar command as root to ensure that you have access to all the appropriate subdirectories, and so that permissions are correctly preserved during creation and extraction of the archive. Possibly the simplest way to do this would be to start the ftp command as root via sudo. If you do so, tar will therefore also be running as the root user, since tar is invoked by the ftp program. You will also need to change to a higher directory and alter the tar command appropriately. e.g.:
$ cd /
$ sudo ftp ftpserver
You will firstly be prompted for your local password to allow sudo to temporarily switch you to the root user. You will then be prompted by the ftp program for your FTP username and password. Once you have logged in, change to the relevant FTP directory using the cd command, and then at the FTP prompt, issue the following:
ftp> bin
ftp> put "| tar cvpf - Users Applications Library" full_backup.tar
Or if you were using older versions of Mac OS X:
ftp> bin
ftp> put "| xtar cvpf - Users Applications Library" full_backup.tar
The extraction would be as follows:
ftp> get full_backup.tar "| tar xvpf -"
Or if you were using older versions of Mac OS X:
ftp> get full_backup.tar "| xtar xvpf -"
Again you would need to make sure the tartt> command ran as root user to ensure a successful restore.
This method could alternatively make use of pax or hfspax in place of tar. However, as I am less familiar with the command line options of pax, I cannot advise of the changes you would need to make to get this to work. You could also use this technique to backup from Linux (or even Windows) onto an OS X machine, assuming you already had appropriate versions of tar and ftp installed on them. Whilst Linux and Windows don't have resource forks, it could be useful to ensure permissions, filenames and other features don't get altered by the FTP process.
