• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Linux server script?

swanysto

Golden Member
Been a long road, but I think I have my ubuntu server mostly figured out. I am using the Windows 7 clients' native program to create images of the hard drives and store them on my ubuntu server. I have them set to do this during non working hours. However, the windows backup program only allows you to keep one copy per computer on the server before it overwrites it. This is problematic, and I am sure those of you who have careless web surfing coworkers, you can guess why.

So I am wondering if there is something I can run on my server daily that creates a folder with the format 8-17-2011 and moves the current image to that folder. I am not super proficient in linux. My google searches just don't seem to come up with what I am looking for.

TIA
swany
 
Check out the date function (date --help) and mkdir.

Here's a sample script that will create a folder of today's date:

Code:
folder=`date +%m-%d-%Y`

mkdir "prefix_${folder}"

I just added the prefix part so you can see the syntax to append so you could put the full path if you want like /backups/${folder} or w/e. There's different ways of doing it but that's one of em.
 
Check out the date function (date --help) and mkdir.

Here's a sample script that will create a folder of today's date:

Code:
folder=`date +%m-%d-%Y`

mkdir "prefix_${folder}"

I just added the prefix part so you can see the syntax to append so you could put the full path if you want like /backups/${folder} or w/e. There's different ways of doing it but that's one of em.

Pretty much what I was going to post.

I went and copied the first part of a backup script I have.

Code:
TODAY=`(set \`date +%Y-%m-%d-%H-%M\`; echo $1)`

tar -czvf /backup/data/data-$TODAY.tar.gz /stuffs

Obviously yours would involving making a directory, and then copying the backup file(s) into it.

Also after you are done with that you can schedule the script to run whenever you'd like with cron.
 
Isn't the windows backup just looking for a file of the same name from a previous job? If so, you could just have a scheduled rename command that runs in a scheduled cron.
I don't know what the backup job file output looks like, but if it is job30.bkf, just rename it.

run man mv to get the manual page for the mv command, which moves or renames a file.
 
Also if you do any copying consider using rsync. Probably not a big deal for this as you're probably just copying one large image file, but for lot of files that may not always change, it makes things go faster.
 
Thanks guys. I was thinking about the rename, but I wasn't sure if that would mess up windows in anyway. I am going to look into this more tomorrow as Linux has exhausted me for the night. I am rather happy I have gotten to the point I have. The only real Linux I have been introduced to is compiling c++ code for classes back in college. I went the programming route, now I wish I had gone the networking route as they had a few Linux courses. Ah well, ya live ya learn.

I post back tomorrow on my findings. I am still trying to work out the kinks with the server. Seems when I mount the NTFS drive to keep the backups, it freaks my network out. For some reason it cuts off my wireless from the router and only allows ethernet to work. It worked when I backed up to the ext3 partition, but Windows claims I cannot restore from that file system.
 
So it ends up that the script will be a lot easier than I thought. Windows creates a folder named "x-pc backups", than creates a folder with the date as the name. Then it throws the backup image in the folder. So all I really had to do was create a mv dir script so that when windows goes to create another backup, it doesn't see the existing file and replace it and its date. Just have to mess with the cron job now.
 
Back
Top