Cycling and bicycle discussion forums. 
   Click here to join our community Log in to access your Control Panel  


Go Back   > >

Foo Off-Topic chit chat with no general subject.

Reply
 
Thread Tools Search this Thread
Old 11-20-11, 07:11 PM   #1
RubenX 
Look! My Spine!
Thread Starter
 
RubenX's Avatar
 
Join Date: Apr 2008
Location: Kissimmee, FL
Bikes:
Posts: 619
I need a very simple backup script for just one folder in Win7

I run a local Minecraft server on one PC here. Me, my son, my daughter, everybody builds stuff on it. Occasionally somebody trips while carrying a lava bucket and the whole town burns like Rome.

Had it been Linux (like it should be), a quikie shel/perl script scheduled in crontab will do. But my Win7 noobness comes into play here.

This is what I need.

* Copy the contents of <some folder> into a <backup folder parent> / <backup dd-mm-yyyy>
* Check all the dd-mm-yyyy and delete whatever is older than 30 days.
* A way to make it run daily, maybe twice a day.

Something simple and native to Win7... I don't wanna get into installing perl for windows or stuff like that.

Recommendations?
__________________
"Hoy es un dia normal, pero yo voy a hacerlo intenso" ~ Juanes
RubenX is offline   Reply With Quote
Old 11-20-11, 08:31 PM   #2
mechBgon
Senior Member
 
mechBgon's Avatar
 
Join Date: Jul 2002
Bikes:
Posts: 6,957
If your version is Windows Pro or Ultimate, use the built-in Backup utility to schedule the backup jobs. Another option is robocopy.exe; I don't have time to dredge up the precise command-line options you'll need right this minute, but can help with that later if you need a hand.
mechBgon is offline   Reply With Quote
Old 11-20-11, 09:21 PM   #3
AEO
Senior Member
 
AEO's Avatar
 
Join Date: Jun 2007
Location: A Coffin Called Earth. or Toronto, ON
Bikes: Bianchi, Miyata, Dahon, Rossin
Posts: 12,258
a fairly comprehensive scheduled backup software is also in win7 HP version.
yeah, it goes down to daily and folder.

I thought it was a bit more comprehensive, but that turned out to be lenovo preload software.
__________________
Food for thought: if you aren't dead by 2050, you and your entire family will be within a few years from starvation. Now that is a cruel gift to leave for your offspring. ;)
http://sanfrancisco.ibtimes.com/arti...ger-photos.htm

Last edited by AEO; 11-20-11 at 09:26 PM.
AEO is offline   Reply With Quote
Old 11-20-11, 10:26 PM   #4
RubenX 
Look! My Spine!
Thread Starter
 
RubenX's Avatar
 
Join Date: Apr 2008
Location: Kissimmee, FL
Bikes:
Posts: 619
Quote:
Originally Posted by mechBgon View Post
If your version is Windows Pro or Ultimate, use the built-in Backup utility to schedule the backup jobs. Another option is robocopy.exe; I don't have time to dredge up the precise command-line options you'll need right this minute, but can help with that later if you need a hand.
I just tried the Win7's native backup. Didn't let chose a destination folder, only a drive... something I can bypass by mounting a folder as a drive. But I have a huntch that the robocopy will fit my needs better. Will try it... thx
__________________
"Hoy es un dia normal, pero yo voy a hacerlo intenso" ~ Juanes
RubenX is offline   Reply With Quote
Old 11-20-11, 10:46 PM   #5
DataJunkie
Senior Member
 
Join Date: Oct 2005
Bikes:
Posts: 14,280
A batch with a xcopy command and pass the date to the folder being created as a variable.
Combine that with a forfiles command to delete the files older than x date. Run said batch in the job scheduler.

Me...I would throw something together in Perl.
DataJunkie is offline   Reply With Quote
Old 11-20-11, 10:47 PM   #6
mechBgon
Senior Member
 
mechBgon's Avatar
 
Join Date: Jul 2002
Bikes:
Posts: 6,957
Or if you have a spare USB flash drive, you could devote that to your Minecraft backup jobs.
mechBgon is offline   Reply With Quote
Old 11-20-11, 11:16 PM   #7
RubenX 
Look! My Spine!
Thread Starter
 
RubenX's Avatar
 
Join Date: Apr 2008
Location: Kissimmee, FL
Bikes:
Posts: 619
Quote:
Originally Posted by mechBgon View Post
Or if you have a spare USB flash drive, you could devote that to your Minecraft backup jobs.
Bingo! I do have 8gb flash that I'm not using because the plastic case broke... the whole folder is just 25mb so, that's it.

and it will even work for total catastrofic pc failure.
__________________
"Hoy es un dia normal, pero yo voy a hacerlo intenso" ~ Juanes
RubenX is offline   Reply With Quote
Old 11-20-11, 11:25 PM   #8
bigbenaugust 
derailleurs are overrated
 
bigbenaugust's Avatar
 
Join Date: Feb 2005
Location: KIGX
Bikes: 2009 Fantom CX, 2012 Fantom Cross Uno, Bakfiets
Posts: 1,972
Is ActiveState Perl still freely available for Windows machines? It's been a LONG time since I put perl on a Windows box without Cygwin.

Otherwise, robocopy or xcopy in batch would do it. Add to your Scheduled Tasks.
__________________
--Ben
Carrboro Bike Coalition - putting the "bike" in "CARrboro" :)
2011 Motobecane Fantom Cross Uno, 2009 Motobecane Fantom CX, and a Bakfiets
Previously: 2000 Trek 4500 (2000-2003), 2003 Novara Randonee (2003-2006), 2003 Giant Rainier (2003-2008), 2005 Xootr Swift (2005-2007), 2007 Nashbar 1x9 (2007-2011), 2011 Windsor Shetland (2011-2014), 2008 Citizen Folder (2015)
Non-Bike hardware: openSUSE Leap - LinuxMint Debian Edition 2 - Mac OS 10.6 - Android 4.4 - CyanogenMod 13
bigbenaugust is offline   Reply With Quote
Old 11-21-11, 08:14 AM   #9
DataJunkie
Senior Member
 
Join Date: Oct 2005
Bikes:
Posts: 14,280
It is still available. I use it on my windows box. I believe strawberry perl is available as well.
DataJunkie is offline   Reply With Quote
Old 11-21-11, 08:54 AM   #10
ModoVincere
Riding Heaven's Highways on the grand tour
 
ModoVincere's Avatar
 
Join Date: Aug 2006
Bikes:
Posts: 1,675
Quote:
Originally Posted by DataJunkie View Post
A batch with a xcopy command and pass the date to the folder being created as a variable.
Combine that with a forfiles command to delete the files older than x date. Run said batch in the job scheduler.

Me...I would throw something together in Perl.
.bat file with copy or xcopy the specified folder.....and a job scheduler. Then sit back and let the fun begin.
__________________
1 bronze, 0 silver, 1 gold
ModoVincere is offline   Reply With Quote
Old 11-21-11, 08:55 AM   #11
StupidlyBrave 
Chepooka
 
StupidlyBrave's Avatar
 
Join Date: Sep 2006
Location: South Central PA
Bikes: 1990 Trek 1400 7spd; 2001 Litespeed Arenberg 10 speed
Posts: 1,167
For linux, I would use rsync & cron
For pc, I would use cygwin rsync & scheduled tasks
StupidlyBrave is offline   Reply With Quote
Old 11-21-11, 09:35 AM   #12
dcrowell
Fat Guy Rolling
 
dcrowell's Avatar
 
Join Date: Jul 2008
Location: Louisville Kentucky
Bikes: Bacchetta Agio, 80s Raleigh Record single-speed, Surly Big Dummy
Posts: 2,439
Robocopy, as mentioned above. Schedule it and forget it.
dcrowell is offline   Reply With Quote
Old 11-21-11, 10:19 AM   #13
jsharr
You Know!? For Kids!
 
jsharr's Avatar
 
Join Date: Apr 2005
Location: Just NW of Richardson Bike Mart
Bikes: '05 Trek 1200 / '90 Trek 8000 / '? Falcon Europa
Posts: 6,153
I would do it by hand. just look at the code and write it down on a legal pad a few times a day.
__________________
Are you a registered member? Why not? Click here to register. It's free and only takes 27 seconds! Help out the forums, abide by our community guidelines.
Quote:
Originally Posted by colorider View Post
Phobias are for irrational fears. Fear of junk ripping badgers is perfectly rational. Those things are nasty.
jsharr is offline   Reply With Quote
Old 11-21-11, 10:20 AM   #14
mikeybikes
Senior Member
 
mikeybikes's Avatar
 
Join Date: May 2009
Location: Edgewater, CO
Bikes: Tons
Posts: 3,214
Quote:
Originally Posted by jsharr View Post
I would do it by hand. just look at the code and write it down on a legal pad a few times a day.
Easier to just open it up in Notepad and print it.
mikeybikes is offline   Reply With Quote
Old 11-21-11, 10:32 AM   #15
jsharr
You Know!? For Kids!
 
jsharr's Avatar
 
Join Date: Apr 2005
Location: Just NW of Richardson Bike Mart
Bikes: '05 Trek 1200 / '90 Trek 8000 / '? Falcon Europa
Posts: 6,153
I was going simple. In my plan, he uses a #2 pencil, hand sharpened, not some fancy high tech machine sharpened pencil and definitely not a mechanical pencil.
__________________
Are you a registered member? Why not? Click here to register. It's free and only takes 27 seconds! Help out the forums, abide by our community guidelines.
Quote:
Originally Posted by colorider View Post
Phobias are for irrational fears. Fear of junk ripping badgers is perfectly rational. Those things are nasty.
jsharr is offline   Reply With Quote
Old 11-21-11, 10:32 AM   #16
SPlKE 
Senior Member
 
Join Date: Sep 2007
Bikes:
Posts: 829
google xcopy and del.

what you need to do is two short lines of easy code that runs in any version of windows.

you use del to delete old stuff and xcopy to copy new stuff

save your two lines of code in a .bat file, and go into scheduled tasks (in your control panels) and set up your bat file to run every day at a specific time

I use xcopy
SPlKE is offline   Reply With Quote
Old 11-21-11, 10:51 AM   #17
HardyWeinberg
GATC
 
Join Date: Jul 2006
Location: south Puget Sound
Bikes:
Posts: 7,376
I like SyncToy esp. for saving daily backups separately. I don't know about going back after a month to delete the older ones but it seems like it should do that.
HardyWeinberg is offline   Reply With Quote
Old 11-21-11, 12:16 PM   #18
somedood
Senior Member
 
somedood's Avatar
 
Join Date: Dec 2006
Location: UT
Bikes: Ibex Xray
Posts: 398
robocopy? perl? Come on people, this is an easy one.

Save this as a batch file, something like 'savefolderdate.bat'

Quote:
@echo off
for /f "tokens=2* delims= " %%a in ('date /t') do set mmddyyyy=%%a
for /f "tokens=1* delims=/" %%a in ('echo %mmddyyyy%') do set day=%%a
for /f "tokens=2* delims=/" %%a in ('echo %mmddyyyy%') do set month=%%a
for /f "tokens=3* delims=/" %%a in ('echo %mmddyyyy%') do set year=%%a

for /f "tokens=1* delims=:" %%a in ('time /t') do set hour=%%a
for /f "tokens=2* delims=:" %%a in ('time /t') do set secondhalf=%%a
for /f "tokens=1* delims= " %%a in ('echo %secondhalf%') do set minute=%%a

set destfolder=%2\%year%-%month%-%day%_%hour%%minute%

IF NOT EXIST %destfolder% mkdir %destfolder%

@echo on
echo copying folder '%1' to '%destfolder%'

xcopy %1 %destfolder% /E /Y
Setup a scheduled task to run this, and give it 2 folders are the source and destination as arguments to the batch file:

savefolderdate.bat c:\full\path\to\folder c:\full\path\to\destinationfolder

This will save everything (including subfolders) in the source folder and put it in a subfolder in the destination named as YYYY-MM-DD_HHMM so it will be a unique folder as long as it isn't run during the same minute. Really the only difficulty is that there aren't any environment variables for the individual parts of the date and time so that's all the first part is doing.
somedood is offline   Reply With Quote
Old 11-21-11, 12:27 PM   #19
DataJunkie
Senior Member
 
Join Date: Oct 2005
Bikes:
Posts: 14,280
I said I would use Perl. I said nothing about him using perl. Egads
DataJunkie is offline   Reply With Quote
Old 11-21-11, 12:46 PM   #20
RubenX 
Look! My Spine!
Thread Starter
 
RubenX's Avatar
 
Join Date: Apr 2008
Location: Kissimmee, FL
Bikes:
Posts: 619
Quote:
Originally Posted by DataJunkie View Post
I said I would use Perl. I said nothing about him using perl. Egads
Hey! I just happen to be the best perl coder in the whole state of Florida... in fact, I can right now tell you, your copy of the perl cookbook from oreilly's is almost broken on page 33, where the list of regular expressions lies.
__________________
"Hoy es un dia normal, pero yo voy a hacerlo intenso" ~ Juanes
RubenX is offline   Reply With Quote
Old 11-21-11, 12:49 PM   #21
mikeybikes
Senior Member
 
mikeybikes's Avatar
 
Join Date: May 2009
Location: Edgewater, CO
Bikes: Tons
Posts: 3,214
Select all the files you want to backup.
Hold down the shift key while pressing the delete key on your keyboard.
When asked if you are sure, click Yes.

All of your files are now backed up.
mikeybikes is offline   Reply With Quote
Old 11-21-11, 01:02 PM   #22
somedood
Senior Member
 
somedood's Avatar
 
Join Date: Dec 2006
Location: UT
Bikes: Ibex Xray
Posts: 398
Quote:
Originally Posted by DataJunkie View Post
I said I would use Perl. I said nothing about him using perl. Egads
I was just trying to poke fun at a fellow nerd, but for the file deletion part I don't see a way around using something outside of what comes with windows. I guess he could use visual basic, but I'm not taking the time to figure that out because of laziness.

Here's a solution that will do mostly what you want. This will keep up to X number of folders, deleting the extras starting with the oldest first. So if you are ok with keeping the most recent X number of backups (rather than backups newer than 30 days old), then this should work fine. name this something like 'deleteoldbackups.bat'

Quote:
@ECHO OFF
FOR /F "skip=%2" %%f IN ('dir %1\*-*-*_* /O:-D /T:C /A /B') DO rmdir /s /q %1\%%f
You'd run this like (same thing, just add to scheduled tasks):

deleteoldbackups.bat c:\full\path\to\destinationfolder 40

If would look in the folder "c:\full\path\to\destinationfolder" for folders that match the date pattern used for backing up, and if there are more than 40 it will delete any after 40 starting with the oldest first. It determines age by the folder creation time, not the file/folder name.
somedood is offline   Reply With Quote
Old 11-21-11, 01:03 PM   #23
DataJunkie
Senior Member
 
Join Date: Oct 2005
Bikes:
Posts: 14,280
Sorry. I am fighting with a piece of code that is besting me. Ergo I am cranky.
DataJunkie is offline   Reply With Quote
Old 11-21-11, 01:07 PM   #24
DataJunkie
Senior Member
 
Join Date: Oct 2005
Bikes:
Posts: 14,280
Quote:
Originally Posted by RubenX View Post
Hey! I just happen to be the best perl coder in the whole state of Florida... in fact, I can right now tell you, your copy of the perl cookbook from oreilly's is almost broken on page 33, where the list of regular expressions lies.
Regular expressions = days of fun.
DataJunkie is offline   Reply With Quote
Old 11-21-11, 01:16 PM   #25
somedood
Senior Member
 
somedood's Avatar
 
Join Date: Dec 2006
Location: UT
Bikes: Ibex Xray
Posts: 398
Quote:
Originally Posted by DataJunkie View Post
Sorry. I am fighting with a piece of code that is besting me. Ergo I am cranky.
Oh man, I feel your pain. There are some days when, after hours of stupid debugging I finally figure it out, and it's like a rush or intense feeling of satisfaction. Most of the time though I have to hang my head in shame because I did something stupid.
somedood is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -6. The time now is 02:28 PM.