If you want to preserve all of the data, you will probably have to create a disk image. Furthermore, Windows cannot recognize typical Linux filesystems, so you probably won't even be able to see your files, when you plug in your SD card.
Creating a disk image will preserve not only files but also the filesystem structure and when you decide to flash your new SD card, you will be able to just plug it in and it will work.
Linux
On Linux, you can use the standard `dd` tool:
dd if=/dev/sdx of=/path/to/image bs=1M
Where /dev/sdx
is your SD card.
Note: An of
image created from a mounted partition on if
may be corrupted. This risk is due to the fact that changes made to if
may be incomplete when copied by dd
. To avoid risk, the if
should be un-mounted during dd
.
Mac
On Mac, you can also use the standard `dd` tool with a slightly different syntax:
dd if=/dev/rdiskx of=/path/to/image bs=1m
Where /dev/rdiskx
is your SD card.
(using rdisk is preferable as its the raw device - quicker)
To find out which disk your device is type diskutil list
at a command prompt - also, you may need to be root; to do this type sudo -s
and enter your password when prompted.
Windows
Option 1
On Windows, you can use the reverse process that you used when flashing the SD card.
You can use Win32 Disk Imager, which is the preferred tool for flashing a SD card of the Foundation. Just enter the filename (the location and name of the backup image file to be saved), select the device (the SD card) and press read:
Of course, you can also use RawWrite, dd
for Windows or similar tools, the process is quite similar.
Option 2
If you don't want to back up your entire system, but only specific files, I suggest you connect to your Raspberry Pi via SFTP and copy the files to your local computer (You can use the WinScp client). If you have SSH enabled, SFTP usually requires no special configuration on the Raspberry Pi side.
Another option is to copy the files to a remote system using rsync.
You can also install special drivers so your Windows can read ext
filesystems (and will thus be able to read the whole SD card), such as ext2fsd
but it is probably not worth the effort.
Since the image will be of the same size as your SD card, you may want to compress it. This can be achieved simply by using your favorite compression tool, such as gzip
, 7zip, WinZip, WinRar ...
git
orhg
, that way you not only have copies of your code in multiple places, but also have the complete history of how that code has changed.