Results 1 to 3 of 3
Hi all,
This is to be part of a cronjob script.
Code:
echo "tar backup directory ".$b
tar zpcf - /home/erind/socprojects_backups/$b | ssh erind at serveripaddress "cat > socProjects.$b.tar"
When ...
- 10-19-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 10
backup script help, sending a tar file to a remote server
Hi all,
This is to be part of a cronjob script.
When I ran my script I got some kind of warning about removing leading / from the directory. Is that bad? The directory I am making a tar file of is the complete filesystem and code I would need to restore a web database if the live version were to crash. Am I doing something wrong that would prevent an easy process of just untarring this file back on the live server if I needed to?Code:echo "tar backup directory ".$b tar zpcf - /home/erind/socprojects_backups/$b | ssh erind at serveripaddress "cat > socProjects.$b.tar"
Secondly, since the cronjob is ran as root, I need to change the ownership and permissions of the tar file to erind, how can I do this if I immediately have the tar file sent to the backup server. Previously my script was just creating a tar file to save on the same server so I had this following the creation of the tar:
chown erin socProjects.$b.tar
chmod u+rw socProjects.$b.tar
Thanks for any help,
Erin
- 10-19-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
The warning about removing leading / is not bad. It just means that you have to be sure to specify that path when you are untarring, if you wish it to get put back in the same place, e.g.:
As to file ownership, my first thought would be, why not run the cronjob as the user? If the user Id does not match up on the remote system, that would not work, though. So why not just add those chown/chmod commands as ssh calls to your backup script? e.g.:Code:tar -C / -xf /path/to/backup.tar
EDIT: Come to think of it, even if the cron is run as root, the file that gets created on the remote server should be owned by whomever you ssh in as - is this not the case?Code:ssh erind at serveripaddress "chown erin socProjects.$b.tar;chmod u+rw socProjects.$b.tar"
Last edited by atreyu; 10-19-2011 at 03:11 PM. Reason: wait...
- 10-19-2011 #3Just Joined!
- Join Date
- Aug 2011
- Posts
- 10
thanks for your help atreyu, im still working out problems with the script but what you said about file ownership makes sense


Reply With Quote