lili.php: list, delete, create, convert symbolic links

name

lili.php - lists, deletes, creates, redirects and swaps symbolic links

synopsis

synopsis:  lili.php opts fun dirs* 

 	fun: 
 		a[ylns]* analyse
 					load FS (from file* or .), 
 					-i*: process inputs if any, as specified by -i, -il, etc.
 					y find redundant directories, write necessary links, e smallfiles, emptydirectories to output to reduce size and number of files/dirs
 					l n s: write liliLink, liliNew, liliStats respectively
 		c[lfdbq]* create l=links, f=small files, d=empty directories andOr remove b=badType, q=removecommands after swap as specified in input (-il)
 		r[lfdbq]+ remove l=links, f=small files, d=empty directories, b=badType andOr q=removecommands after swap as specified in input (-il)

	opts 
	 	-il file    read liliLink or liliNew (.csv ot .txt)
	 	-iL			= -il liliLink.csv
	 	-ij file   read jdupes output file
	 	-iJ         = -ij jdupes.txt
	 	-ir file    read rdfind result file
	 	-iR         = -ir results.txt 

files:

  • liliLink: contains all links, smallfiles and rm-cmds after reduce
  • liliNew: contains all files, directories, links, smallfiles and rm-cmds after reduce
  • liliStats: contains files and directory with delta-size > threshold

Description

the problem

with Man:jdupes orrdfind you can replace redudant files by symoblic links and save a lot of space. However

  1. the links created are absolute links, if you copy the data to a different media, the links still point to the original location, probably not what you want
  2. even if they are relative links the tool to copy over the network, do different things with the links, often not what you want
  3. Many filesystem do not support symbolic links or copying symbolic links. It would be nice, to copy the data without links and recreate them later
  4. If you want to delete an older part of the data, you do not want to get dangling links, from the newer part to the deleted part.
  5. furthermore, to create links for redundant directories would reduce the data even more

the solution

lili.php allows you

  1. to convert absolute to relative links
  2. list, delete, recreate symbolic links
    • list all links in a (list of) directories to a flat file (lili.link)
    • delete all links
    • to recreate links from above lili.link file
  3. to swap links with targets, such that all links will point into the desired direction (e.g. from old to new)
    • to delete directories, after doing the necessary swapping to avoid dangling links / lost data

lili.php Walks through die directory tree in the specified order and process symbolic links. As described under functions, links are listed and converted into relative links, swapped (with target), redirected or deleted.

Finally links can be recreated from a list of links create previously.

It's written in PHP, because your hosting provider most likely supports PHP.

functions

    scan filesystem to find directories, files, links etc.
    read output from rdfind or jdupes, for redundant files, liliLink or liliNew and merge it with info from filesysten
    liliLink or liliNew may contain remove commands
    analyse tree to find redundant directories, files small files and empty dirs
    use a regexp, to designate filenames that should be removed
    write csv:
        statistics
        links, redundancies, empty files and dirs
    change filesystem
        replace redundant files/dirs by links
        remove empty dirs, small files links
        recreate empty dirs, small files links

the normal procedure

    * go into directory
    * jdupes -rM  * >jdupes.txt # jdupes.txt with redundant files 
    * rdfind -dryrun true *		# or create results.txt with duplicate files using
    * lili.php -iR aylns .		# create liliLink.csv etc. with the reduced file and dirs
    * lili.php -iL clbq			# swap, create links remove bad or removeCommands
    *                           # now all redundand files and dirs are replaced by links with no data loss ==> diff -r to compare to original
    * lili.php aylns .          # write liliLink.csv for current state

transfer to different system

    *  lili.php -iL rfdl        # remove links, small file and empty dirs	
    *  cp to new destination and to into the new destination
    *  lili.php -iL cfdl        # recreate links, small file and empty dirs	in new destination

deleting dirs/files

    * edit liliNew.csv (or liliLink.csv), enter in column stNew
       * rm1 to remove this file/dir
       * rmR to remove this file/dir and all redundant
    * lili.php -illiliNew.csv aylns .		# create liliLink.csv etc. with the reduced file and dirs
    * lili.php -iL clbq						# swap, create links remove bad or removeCommands