Back and Rollback Script for a File Transfer - powershell

I looking for a good solution to backup and rollback a folder using the Windows(XP/Vista/7) OS.
As an example, say, I have a folder, called "\SOMEOTHERPC\Destination" (that contains files and subfolders). I wish to take a back up of this folder to my local disk. Then, say I was to edit or delete some of the content of this "\SOMEOTHERPC\Destination" folder and the afterwards rollback the folder to its previous state.
What's the best way to go about this. I am thinking of writing a PowerShell script? Perhaps there is a better way. Any suggestions appreciated?
Thanks.

RoboCopy seems to do the trick requiring just a couple of lines of script.

Related

Simple yet fast deployment tool or solution for FTP-based server

I have a simple task to which some simple solution should exist yet I cannot come across one.
I have a huge file tree on computer A (development). I have the same (multiple) such file trees on a computer B (let's call it production). Computer B runs FTP and PHP, nothing much else.
I need to move the changed files from the tree on A to the tree on B but as efficiently as possible. I.e. if just one file changes, it will just transfer that one file. It would be enough to "compare" the local and remote trees using last modification dates, nothing else needed.
I tried to use the good old Ant for it but that really does not work as the FTP task is really bad one there (does not preserve modification dates on PUT and so on). What other options are there if I do not want to write the code for such a task myself? I'd expect there is some tool out there that would make a remote dir listing, download it to local computer, select only those changed files and transfer them to the destination. Do you know how I could do it? Some sort of FTP or PHP-based distributed robocopy?
EDIT: I should have added that I mean doing it on a Windows 10 computer syncing to some FTP/PHP server using command-line automated script, not GUI.
Actually I solved the issue using winscp. I managed to integrate it into ant calling it through the task and using the winscp's synchronize command. For my current folder size it is fast enough, let's see later. The FTP command in ant was not useful since it does not preserve the modification dates.

How to set directory-property comments

I'm trying to find a way to set comments with powershell for a directory.
How can I set for a folder comments (like contains contact files)?
Thanks for infos
This is a quite interesting question so i quickly did a bit of research. It is not as trivial as one would hope. In fact at least on W10 its basically impossible to do it via UI but i found a way to do it with Powershell:
First you have to make the Folder a system folder (somehow comments are only shown on system folders on my machine, got to test on yours yourself):
attrib +s <Folderpath>
Not sure if we can do it with a cmdlet (probably but no time to research right now).
Then you have to create a "Desktop.ini" file inside the folder like so:
"[.ShellClassInfo]","Infotip=YOUR COMMENT HERE"|Out-File <Folderpath>\Desktop.ini
and thats basically it :)

Robocopy a specific folder

We use a folder template for our projects we work on and my normal process to log each job is to right click, copy, rename, make shortcuts, etc... It's like a 5 minute process after everything is said and done. For right now the idea is to just copy that template folder, rename, make shortcuts, and send those shortcuts to the appropriate directories. This issue I'm having is that when I run robocopy it is copying the contents and not the template directory itself. A snippet of what I have right now is:
robocopy \\Users\blah\blah\DirectoryIWantToCopy \\Users\blah\blah\CopiedDirectory /e
As of right now when I run it, it is copying everything inside the directory instead of just copying the parent directory. I understand why it's doing it, but it seems as though the only way to accomplish what I'm doing is to exclude all the directories inside \Users\blah\blah\ that I don't want it to copy. Is there not a switch to add that just says copy this specific directory and all sub directories of this specific directory? I'm sure that is as simple as it sounds, and I'm sure I'm overlooking it, but from all the other questions I've googled I haven't been able to find an answer that answers this.
So when I read the information about the switches on Technet it kept referencing a file, and thought that only meant an actual file and not a directory. I got it to work by simply adding the file name after the destination. Thanks.

On iOS, how can an app determine if a file is no longer being written to by another process?

My question is very similar to this one: What is the optimal way to monitor changes in a directory with a kqueue()? but I'm not satisfied with the answer there.
I have a kqueue setup to be notified when a file is copied to my app's Documents directory. Of course the notification fires as soon as the copying begins, but I want to know when it's completed. Surely there's a better way than polling modification times?
Do you initiate the copying and have control over the filenames ?
Then the easiest solution could be to just copy to a temp file and then after that rename it to it's final name.that way you would know: if this file is there-it ist no longer written to.
For now, the answer seems to be 'no', so I've resorted to polling the modification time of the file(s) in question.
If someone else is able to come up with a better answer, I'd be glad to hear it (and will un-accept this one).

Automated versioning of files in file share?

We have a file share on a debian server which people will be putting mostly small plain text, word, excel, pdf, misc, files into. We want to keep file level versioning of everything placed in that file share. We'd like all of the versioning to happen automatically in the background every time a change is made to a file.
What's the easiest open source way to do this? What's the best versioning system to do this with? Is there an automated versioning system like this out there somewhere?
I'm not asking for complete instructions. I'm just looking for recommendations or keywords to search with (other than "automatic versioning files" which didn't find me much).
We're already backing up the volume many times a day. We don't want to do volume snapshots etc. We're looking for some kind of automated file level versioning.
Update:
Using incron to autocommit changes in a folder:
http://andrew.mcmillan.net.nz/blog/using_incron_to_autoversion_a_directory
Thanks to using the new keyword "autoversioning" I found the above which I'm interested in. It's a script which is triggered from incron every time a file changes. One problem is incron isn't recursive.
I would try a versioned filesystem, such as ext3cow or nilfs.
I have no experience with them, but they have always looked like a very interesting idea to me.
The SVNAutoVersioning directive to mod_dav_svn is one solution.