Create a hardlink to an open inode - inode

I deleted an ext3 file by accident. But I had a (fresh) backup copy so I put it back.
Unfortunately the file was opened at the time of deletion, so now it exists in 2 copies: the visible copy and the invisible copy. The invisible copy is still written to and it's going to be deleted once the file is closed.
Is it possible to undelete the invisible copy?

The answer is to copy proc/{pid}/fd/{handle} file. The handle can be found by lsof and other means.

Related

cannot zip locked access file

I am writing a powershell script which creates a zip file of a local folder:
[System.IO.Compression.ZipFile]::CreateFromDirectory('c:\myfolder\', 'c:\myarchive.zip', [System.IO.Compression.CompressionLevel]::Fastest,$true)
This folder contains an MS-Access database. This database is opened at the same time by another user. I cannot ask him to close this database.
The zip operation fails because the database is locked. Is there a way to bypass this lock and make a copy of the database ?
Thanks a lot
Copy the folder to a temporary place and zip the copy.

How to overwrite existing files with ncftpget?

When getting a remote ftp file that exists in the local destination
ncftpget says that
local file appears to be the same as the remote file, download is not necessary.
What does appears mean? How does ncftpget check if this is the same file?
It seems that it compares time and size of the file. But does it compare content or at least checksum?
Is there a way to force to overwrite the existing file. Of course other than remove it first.

How does nxlog track the line number?

In nxlog config I have these params set:
SavePos True
ReadFromLast True
When removing lines from a log file (this should never happen) nxlog ships the entire log file. Is this related to how nxlog tracks the line number?
To recreate:
I stop the nxlog service
Delete the nxlog cache (just to make sure im starting fresh)
Right now the log folder ive configured nxlog to watch is empty
I add a new log file to the folder
nxlog ships the log file
I open the log file and add a few lines
nxlog ships those lines
I delete those new lines I just added
nxlog ships the entire log file
NXLog and generally other log shippers are designed to deal with append-only log files.
When you delete lines from the log file it sees that the file size is less. Under the append-only assumption this can only mean that the file was replaced/rotated and the current file is a new one that needs to be fully read.
Also note that when you edit a log file in a text editor the editor will usually replace the file with a new one even if you only append data to the end. This is not equivalent to echo test >> test.log.
If you want to transfer all kinds of changes in files you should use rsync or other tools.

how to use backup files to create regular files in emacs

I am trying to create a file named caseexp.sml . Emacs created a backup file of this file when I was working on it at some earlier point, and now when I try to open it as caseexp.sml, emacs opens a #caseexp.sml# file and everytime I try to save it using C-x C-w, emacs saves it as another backup file with another tilde added to its name. Several attempts later, I have only managed to save it as #caseexp.sml"~~~.
How can I avoid creating these "tilde" backup files and save my file simply as caseexp.sml ?
There are a few unexpected behaviors here, so I can't be sure that this is what's going on, but usually what happens is that if files with hashes are left around, it's possible that Emacs crashed while you had unsaved changes. However, usually Emacs should prompt you to run "M-x recover-this-file" to restore changes from the unsaved-changes file (the filename with the hashes) to the actual file, so it's not clear what's going on there. Try fixing this from the command line.
You probably want to cp all the files to another location first, in order to have a backup (I'm assuming a Unix-like OS):
$ cp *caseexp* /tmp
Then delete the extra files while preserving the one with the most recent changes:
$ cp <most recent file with latest changes> caseexp.sml
$ rm \#caseexp*

How to automatically duplicate copy contents of one folder to another folder on a different disk?

I have a folder in im c:/ drive (lets say C:\users\myname\python). Every time I create new files in that directory, is it possible to have those files automatically copy to a folder on my d: disk (d:\"magic briefcase").
The main reason I want to so this is that on my d: disk I have the "magic briefcase" of the sugarsync program set up. This lets me share the contents of that folder with my other computer in real time (which has the same "magic briefcase" folder).
since python is installed on my c: disk, I need to save my .py files on the the c disk, but of course "magic briefcase" folder is on my d: disk. So will be great to have the contents of the c: disk automatically forward to the d: disk.
Is this possible???
Thanks
Darren
mklink /J "D:\magic briefcase\python" C:\users\myname\python
should do what you want, I think.
That creates a "junction" aka hardlink between the two directories. Essentially you have one directory that's accessible via two different paths. Add a file to one of them, and it just is in the other one - no copying needed. Ditto for deletes, edits, etc.